+ 5
prompt() in JS gives you string, how to have number?
When I use prompt() in JavaScript, I receive a string variable. What do I do so that prompt() gives a number variable, or is there another way besides prompt() ?
6 ответов
+ 4
For example,
var a=prompt();
alert(parseInt(a)+1);
+ 4
tq
+ 4
Be careful, in some situations it returns null.
+ 3
@Petr Show me how to use it pls
+ 2
Its not work...
https://code.sololearn.com/W22Oei0bWsS7/?ref=app
0
parseInt(string) is integer in JavaScript.