Menu
I am very new to Javascript so please bear with me. I would like to do something simple like pass a variable, have the variable rounded off and then printed. Here’ the code I am trying:
[CODE]
var x = prompt(“Enter a number to round”, 1);
x = x + 0.5;
document.write(“<p>” + x + “</p>”);
x = parseInt(x);
document.write(“<p>” + x + “</p>”);
I expect this should output 1.5 and 2, but this is the output I get:
1.50.5
1
Any insight would be appreciated.