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

Kevin Naegele
Kevin Naegele
10,868 Points

parsing-numbers-from-strings

I am trying the code challenge but on the first question it is asking for var numWidth using parseInt. But after inputting the correct code, it says wrong we need numVariable using the parseInt as well, but it does not recognizes the numVariable?

I have tried to browsers and reset all cache and cookies in both.

var numWidth = parseInt("640", 10);
var numVariable = parseInt("480",10);

Any idea?

4 Answers

Hi KeVin,

I don't see anything about a variable named numVariable. Also, you want to do something more like this: parseInt(boxHeight, 10).

Question 1.) A variable named "boxWidth" already exists with a value of "640px". Create a new variable named "numWidth" and use the "parseInt" method to extract the numeric value from boxWidth's string value.

Question 2) Similarly, a variable named "boxHeight" already exists with a value of "480px". Create a new variable named "numHeight" and use the "parseInt" method to extract the numeric value from boxHeight's string value.

Jeff

Kevin Naegele
Kevin Naegele
10,868 Points

I keep getting this on the first question.

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

is this not correct? var numWidth = parseInt("640", 10);

var numWidth = parseInt(boxWidth, 10);
var numHeight = parseInt(boxHeight, 10);
Kevin Naegele
Kevin Naegele
10,868 Points

I keep getting this on the first question.

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

is this not correct?
var numWidth = parseInt("640", 10);

Kevin Naegele
Kevin Naegele
10,868 Points

Face palm! I can not believe i missed that. Thank you Jeff