Just got started with Javascript and struggling with some pretty easy code:
"use strict";
function math () {
if (action == "+") {
return answer = firstNumber + secondNumber
}
else if (action == "-") {
return answer = firstNumber - secondNumber
}
else {
while(action != "+" || action != "-") {
action = prompt('Write an action (only "+" and "-" supported!!!):');
}
}
}
math(firstNumber, secondNumber,action);
alert(answer);
Even after condition in loop is false the loop still executes. Can you please explain what went wrong? Not just solution, please.