I'm making a calculator in JS that displays commands and the result in a prompt.
I want to add an action that, after receiving the result of the operation, makes it possible to multiply, divide, etc. by another number.
Action plan: First action... = result > choose selector ( +, -, *,/) > choose second number > result --- and so on until you stop pressing enter with a blank field.
I was thinking of starting with a while loop to add the ability to choose a character but I don't know if it will affect the result of the previous action, additionally I don't know how to add the ability to choose the next number
switch (operator) {
case '+':
alert(numb1 + numb2)
break
case '-':
alert(numb1 - numb2)
break
case '*':
alert(numb1 * numb2)
break
case '/':
alert(numb1 / numb2)
break
case '%':
alert(numb1 % numb2)
break
}
while (true) {
let result = +prompt('Enter an arithmetic operator or leave blank.')
if (!result) break
}
}