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"); }

20th Aug 2016, 11:05 AM
Oscar
Oscar - avatar
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 == '*')
20th Aug 2016, 12:45 PM
Saif Ali Khan
Saif Ali Khan - avatar
0
Thank you.
20th Aug 2016, 1:24 PM
Oscar
Oscar - avatar