+ 5

Why it didn't work? Code in anotation.

https://code.sololearn.com/WRg5zWehTBVI/?ref=app I'm not too strong in JavaScript and in coding in general

3rd Dec 2017, 12:02 PM
Demid Metelnikov
Demid Metelnikov - avatar
3 Answers
+ 7
// It works, you needed to make some tweaks in it... var x = Number(prompt("Please enter first number")); alert(x); var c=prompt("Please enter operation"); alert(c); var y=Number(prompt("Enter second number")); alert(y); var res; switch(c){ case "+": res=x+y; break; case "-": res=x-y break; case "*": res=x*y break; case "/": res=x/y break; }; document.write("Result is:"+res);
3rd Dec 2017, 12:39 PM
Dev
Dev - avatar
+ 2
OK.Thanks for answer
3rd Dec 2017, 1:19 PM
Demid Metelnikov
Demid Metelnikov - avatar
+ 1
Code Fixed: /*This is JavaScript code Creator Demid Metelnikov*/ var x = prompt("Please enter first number"); var c=prompt("Please enter operation"); var y=prompt("Enter second number"); var res; switch(c){ case "+": res=x+y; break; case "-": res=x-y; break; case "*": res=x*y; break; case "/": res=x/y break; } document.write("Result is:"+(res));
1st Jan 2018, 11:29 PM
Fares Younis
Fares Younis - avatar