Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Unsubscribed User
7,386 PointsUsing the 'parseInt' to get the 'totalWidth'. The message I keep getting is, Did you use the `var` keyword to create the
This is the Bummer message I keep getting.
Did you use the var
keyword to create the totalWidth
variable?
4 Answers

Krzysztof Kucharzyk
Front End Web Development Techdegree Student 4,005 PointsTry this:
var width = '190px';
var numOfDivs = 10;
var totalWidth = parseInt(width) * numOfDivs;

Unsubscribed User
7,386 Pointsvar width = '190px'; var num = parseInt(width); var numOfDivs = 10; var totalWidth = (width * numOfDivs);
Hi Chyno, This is the code I used.

Unsubscribed User
7,386 PointsAnd Krzysztof saves the day! If I may ask, where did you learn this? This pattern wasn't in the lesson/video nor in the teacher's notes.

Krzysztof Kucharzyk
Front End Web Development Techdegree Student 4,005 PointsWell sometime it's good to look for some methods/functions documentation to see what does it do before you use them. Like in this case read this MDN documentation about parseInt ;)
I took a look at this challenge to check if numOfDivs is a string variable or an integer and if width is a string you have to parse with.
So in this case if numOfDivs would be a string variable your function would look like:
var totalWidth = width * parseInt(numOfDivs);
But in this case it's integer and width is a string you have to parse so your code is like:
var totalWidth = parseInt(width) * numOfDivs;

Sandy Jones
7,854 PointsI keep getting the same message and here is what I did: var width = '190px'; var width = parseInt(width); var numOfDivs = 10; var totalWidth; var totalWidth = width * numOfDivs;
keep getting the message: Did you use the 'var' keyword to create the 'totalWidth' variable?
Chyno Deluxe
16,923 PointsChyno Deluxe
16,923 Pointsplease provide your code.