Can i convert string to int in js | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can i convert string to int in js

Example : if user inputs some number from input box by html the javascript takes that value as string so how can i make it a int as we do in python

27th Oct 2021, 6:25 AM
Deepak Kanojiya
Deepak Kanojiya - avatar
2 Answers
+ 2
you can use let num = Number.parseInt(string); (You can ommit the “Number.” If you want)
27th Oct 2021, 6:37 AM
Guillem Padilla
Guillem Padilla - avatar
+ 2
a=prompt(”Enter an integer value :”); p=parseInt(a); The above steps can take input and convert it to integer format
27th Oct 2021, 6:38 AM
sree harsha
sree harsha - avatar