+ 1

Prompt to Number Conversion?

If I prompt a question that entails a numerical answer (200, for example), how can I use 200 as a number rather than a string in future commands?

7th May 2017, 9:39 PM
Ben Galbraith
1 Answer
+ 2
For an example; var x = Number(prompt("First num")); var y = Number(prompt("Second num")); alert(x + y); Or var x = +prompt("First num");
7th May 2017, 10:05 PM
Adem Şahin
Adem Şahin - avatar