Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Numbers Parsing Numbers From Strings

Eliezer Hutton
Eliezer Hutton
6,207 Points

Stuck on a Parsing Numbers challenge

I don't really know what i'm doing wrong here, and would appreciate any input: The challenge is to create a new variable named "numWidth" and use the "parseInt" method to extract the numeric value from boxWidth's string value. The given code is: var boxWidth = "640px"; var boxHeight = "480px";

and i have input: var numWidth = parseInt("640px", 10);

and received this error message: Bummer! Sorry! That's not correct. A correct answer will use the form: var numVariable = parseInt(stringVariable, radix);

I really can't see where i've gone wrong here, unless i've misunderstood the wording of the question, any help is appreciated

2 Answers

You're doing everything okay as far as the syntax goes, but you're missing the point of the task. You should be passing the boxWidth variable to the parseInt function, not a string literal.

Eliezer Hutton
Eliezer Hutton
6,207 Points

Thank you very much for the help, all good now.