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


Brandon Thomas
Brandon Thomas
6,229 Points

Code Challenge: Parsing Numbers From Strings


I am stuck on the first part of this challenge and I am not sure what I am doing wrong here. I feel my code is correct I have tried several different iterations to no avail.

var boxWidth = "640px";
var boxHeight = "480px";
var boxWidth = parseInt ("640px", 10);
James Barnett
James Barnett
39,199 Points

I noticed the formatting of code blocks didn't seem quite right, so I fixed it.

For future reference, code blocks use 3 backticks ` (on a standard US keyboard layout it's on the key to the left of 1 key), as opposed to 3 single quote mark.

If you are still confused check out this thread on how to type code in the forum for some examples.

2 Answers

James Barnett
James Barnett
39,199 Points

On line 3, use the varibale name boxWidth instead of the contents of that variable.

In addition to using the variable name (boxWidth) in the parseInt function instead of the contents of the variable, note that you don't have to declare a new variable there because boxWidth already exists. You want to take boxWidth and assign it a new value based on the old one.

For example:

var num = 2;
num = num + 1;

Here, num takes on the new value of 3 and you didn't have to declare it again because it already existed