Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSimona Diarrova
5,654 PointsParsing numbers from string - challenge N#1
How to create a new variable which extract a number value from another variable. var boxWidth = "640px"; create a new variable numWidth and using parseInt extract the number value from var boxWidth.
Thank you very much for help.
4 Answers
Bertan Ulusoy
18,047 PointsYou should write that code like that: var numWidth = parseInt(boxWidth, 10); We use 10 for radix because the radix parameter is used to specify which numeral system to be used.
Simona Diarrova
5,654 Pointsvar numWidth = parseInt(boxWidth, 10);
Bertan Ulusoy
18,047 PointsWhile I was writing, I did not see your answer Simona.
Bertan Ulusoy
18,047 PointsYou're welcome :)
Simona Diarrova
5,654 PointsSimona Diarrova
5,654 PointsThank you Bertan. I already answered that question 5 min ago but thank you I was stacked on that one for a while.