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 trial

JavaScript JavaScript Foundations Numbers Parsing Numbers From Strings

Simona Diarrova
Simona Diarrova
5,654 Points

Parsing 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
Bertan Ulusoy
18,047 Points

You 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
Simona Diarrova
5,654 Points

Thank you Bertan. I already answered that question 5 min ago but thank you I was stacked on that one for a while.

Simona Diarrova
Simona Diarrova
5,654 Points

var numWidth = parseInt(boxWidth, 10);

Bertan Ulusoy
Bertan Ulusoy
18,047 Points

While I was writing, I did not see your answer Simona.