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 trialNazaam Kutisha
7,667 PointsI Need Help with this challenge.
My response was:
var numWidth = parseInt("640px", 10);
My answer isn't accepted by code engine.
```<!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>```
4 Answers
Adam Moore
21,956 PointsThis particular challenge is asking you to use the variable boxWidth
that has the value of "640px" for the parseInt()
method, not simply manually writing in the "640px" into the parseInt()
method. So, var numWidth = parseInt(boxWidth, 10)
would work.
Ryan Drake
12,587 PointsI assume you want to change numWidth to boxWidth? The parseInt will work as intended.
Nazaam Kutisha
7,667 PointsIts a string, the challenge asks you to use parseInt
to extract the integer from the string.
Nazaam Kutisha
7,667 PointsGood it worked. I tried it that way first, but used "" around the boxWidth variable so it wasn't passing.
Adam Moore
21,956 PointsAwesome! Glad I could help!