Good afternoon, please help with checking the values for this calculator. I know what can be done differently, but how exactly to check this one out.
Via do {var c = prompt("Введите действие которое вы хотели бы совершить: +, -, *, /, %");} while (c === "+" || c === "-" || c === "*" || c === "/" || c === "%") - does not work.
I apologize for such questions, but I do not want to leave without understanding.
<!DOCTYPE html> <html> <head> <title>Калькулятор</title> <meta charset="utf-8"> </head> <body> <script type="text/javascript"> var res; function sum(a, b) { res = a + b; alert(res); } function sub(a, b) { res = a - b; alert(res); } function mul(a, b) { res = a * b; alert(res); } function div(a, b) { res = a / b; alert(res); } function rest(a, b) { res = a % b; alert(res); } do { var a; do { a = +prompt("Введите первое значение"); } while( isNaN(a) || a == ' '); var c = prompt("Введите действие которое вы хотели бы совершить: +, -, *, /, %"); var b; do { b = +prompt("Введите второе значение"); } while (isNaN(b) || b == ' '); switch (c) { case "+": { sum(a, b); } break; case "-": { sub(a, b); } break; case "*": { mul(a, b); } break; case "/": { div(a, b); } break; case "%": { rest(a, b); } break; } exit = confirm("Продолжить?"); if (exit) { document.write("Вы завершили выполнение."); } } while (exit); </script> </body> </html>