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

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