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

Help!

I don't understand why var numWidth = parseInt("640", 10); is not working for code challenge task one on parsing numbers from a string. Can anyone help. This is truly starting to frustrate me.

<!DOCTYPE html> <html lang="en"> <head> <title>JavaScript Foundations: Parsing Numbers From Strings</title> <link rel="stylesheet" href="core.css"> <script> var boxWidth = "640px"; var boxHeight = "480px"; var numWidth = parseInt("640", 10);

</script>

2 Answers

J Scott Erickson
J Scott Erickson
11,883 Points

You actually want to pass the string variable as the first argument into parseInt() likse so:

var numWidth = parseInt(boxWidth, 10);

Thank you so much. I was wondering what was to reference the initial variables. I was on the right track. But this was very tricky to me. Thanks again. I really appreciate it.