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 trialRicard Taujenis
4,383 PointsImagine you have 10 <div> tags on a web page. Each div is 190 pixels wide. Using the two variables in this script, creat
Can not find NumofDivs
var width = '190px';
var numOfDivs = 10;
var totalWidth =parseInt(width) * parseInt(numofDivs);
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
3 Answers
Jennifer Nordell
Treehouse TeacherWow! You're so close it's silly. You're off by one letter. You declare numOfDivs then try to parseInt of numofDivs. Note the capital O. Your last line should be:
var totalWidth =parseInt(width) * parseInt(numOfDivs);
Carlos Federico Puebla Larregle
21,074 PointsYou actually don't need to "parseInt" the numOfDivs variable, it's already an "int".
var totalWidth = parseInt(width) * numOfDivs;
I hope that helps a little bit.
Ricard Taujenis
4,383 Pointsaw ok thx was a little confused in the video guide he also parseInt 2 functions in the same var guess it dosnt apply to all cases :)
Ricard Taujenis
4,383 PointsMhm still dosnt work :/
Carlos Federico Puebla Larregle
21,074 PointsRemember that JavaScript is case sensitive, in your code you have the "o" character from the "numOfDivs" variable that you are multiplying by the parseInt version of the variable "width" written in lower case. So you have to put it in uppercase, like this:
var width = '190px';
var numOfDivs = 10;
var totalWidth = parseInt(width) * numOfDivs;