How do I do this in javascript?
I have a variable. It has the value "7", and I want to convert the value into 7. How do I do this?
Voters
Ask coding questions
I have a variable. It has the value "7", and I want to convert the value into 7. How do I do this?
Use
parseInt()
.@Wumi4 Can you do it similarly with ""string"" and "variable"?
@Wumi4
Number()
also works fine.@ia13ru That would convert to
NaN
because"string"
is not a number. "string" isn't a number it's a word, so it can't be converted into one.@Wumi4 Thanks :-)