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 Basics (Retired) Working With Numbers Numbers and Strings

Ricard Taujenis
Ricard Taujenis
4,383 Points

Imagine 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

app.js
var width = '190px';
var numOfDivs = 10;
var totalWidth =parseInt(width) * parseInt(numofDivs);
index.html
<!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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Wow! 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
Carlos Federico Puebla Larregle
21,074 Points

You 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
Ricard Taujenis
4,383 Points

aw 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 :)

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,074 Points

Remember 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;