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 trialBrooke Casey
4,835 PointsI think that there is an error with the test for parseInt for Javascript Foundations.
I think that there is an error with the test for parseInt for Javascript Foundations.
This does not pass...
var numWidth = parseInt("640px", 10);
3 Answers
Alex Heil
53,547 Pointshi Brooke Casey , actually you're very close to the right answer already. you created the variable correctly and you're also using parseInt.
however when we look at the question (btw: it's always good to post the full question when you start a topic so we can see your code in a context): 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.
the question wants you to use the already existing value which is stored in a variable and not to write the value of the variable into the function. if you already have code in a variable it's good to use the variable instead, so if you later want to change something you only need to change it once (in the variable) instead of changing the 640px manually on multiple places.
so to round this up, I hope I explained it well, here's what the full code - using the existing variable - would look:
var numWidth = parseInt(boxWidth, 10);
hope that helps and have a nice day ;)
Jeff Busch
19,287 PointsHi Brooke,
Hint: if you put a value into a variable you might as well use the variable.
Jeff
Tracey Dolby
5,638 PointsThanks Alex and Jeff, this answers my question about this also. However, the videos don't touch on this, in fact is shows us that if you don't use a number at the beginning of the parenthesis, the code won't run. I'll give this a shot and see how it goes.
Thanks again, Tracey