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

This challenge is really annoying.

I have tried everything and still not allowing me to move on to the next level. 640 is displaying in the console.log. what am i doing wrong? The question is a variable named "boxWidth" already exists with a value of "640px" create a new variable name "numWidth" and use the "parseInt" method to extract the numeric value from the boxWidth's string value.

index.html
<!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("640px",10);



    </script>
  </head>
  <body>
    <h1>JavaScript Foundations</h1>
    <h2>Parsing Numbers From Strings</h2>
    <script src="viewer.js"></script>
  </body>
</html>

2 Answers

What you have works, but they want you to use the boxWidth variable as an argument in the parseInt function. Try this:

var numWidth =  parseInt(boxWidth, 10);

thanks for making it clearly to me.

Np :D