The thing is i want is the user to enter the limit of the numbers he or she wants to divide and then i can divide them . Like the user says limit is 4 and then enters numbers like 60/2/3/5 to give 2.
case 'division':
function division(){
let num = 0;
let division = 1;
let div=division
let i = 0;
window.ask=prompt('Enter the limit of the numbers to be multiplied');
while(i<window.ask){
let num=parseInt(prompt('Enter the numbers one by one '));
division= num/division;
if(division=num){
div=div/num;
}
i++;
}
alert("The result is "+div);
}
division();
break;
I tried this expecting that after entering the first number it would divide by 1 and if the division was equal to the number stored in the variable 'num' then div would divide the division result with the value stored in 'num' that is entered in the next round by the user but i got stack as the result of 60/2/3/5 was 0.0005 and in addition i want to be using while loop to be able to calculate any limit the user can enter not just like 3 0r 4 numbers.
So there are couple of mistakes in your code. Let's look at them one by one.
divisionfor the first time.Below is the code that will address the above issue to give you the expected output.
EDIT:
=== operator in javascript.