+ 3
how to convert string to number?
Javascript I'm trying to use two numbers from the user input, (e.g. when I try to add input1+input2+123 ) input2 is added to 123 and input1 is just joined (58+2+123 results to 58125)
4 odpowiedzi
+ 3
Im assuming in Java.
Integer.parseInt(string);
Float.parseFloat(string);
Double.parseDouble(string);
Example:
// inside main method
String str = "42";
int num = Integer.parseInt(str);
+ 2
The language is Javascript in html. (Thanks for your response)
+ 2
There are parseInt() and parseFloat() functions:
var str = "42";
var num = parseInt(str);
0
Which programming language?