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

Michael Criste
Michael Criste
5,045 Points

var numWidth = parseInt("640px", 10); This is my answer, and it runs just fine on the Chrome DevTools. Please help.

The quiz won't pass me. Please help.

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

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

2 Answers

Jeff Jacobson-Swartfager
Jeff Jacobson-Swartfager
15,419 Points

You need to perform parseInt() on the boxWidth variable instead of doing it directly to the string "640px".

This one tripped me up as well. Really poor show on Treehouse part as the preceding videos make no mention at all of parsing variables directly. Yes, a bit of thinking and searching will solve it but the point is we're paying to learn, not to be frustrated by things we have no concept of at a given point.