0
Code not working.
var x = prompt(Enter x) alert(x); var op = prompt(Enter operator) alert(op); var y = prompt(Enter y) alert(y); function Calculate() { if (op = *) { alert(x * y); } if else (op = /) { alert(x / y); } if else (op = +) { alert(x + y); } if else (op = -) { alert(x - y); } else { alert("Error"); }
2 Respostas
+ 1
Every statement should end with a semicolon.
Your prompt function should end with it too - prompt();
Inside the prompt your string should be double quoted - prompt("Enter x");
To compare something you should use the comparison operator == and every single character should be between single quotes - if(op == '*')
0
Thank you.