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

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

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.

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

var numWidth = parseInt(boxWidth, 10);

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

You're welcome :)