+ 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
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);
+ 2
OK.Thanks for answer
+ 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));