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 Numbers Working with Numbers Numbers and Strings

JavaScript numbers challenge task 1

For the first part of the task I came up with this cold however for some reason it doesnโ€™t seem to work.

script.js
const width = '190px';
const totalImages = 10;
parseInt(width);

let totalWidth = totalImages * width; 

1 Answer

Martin Sole
Martin Sole
82,199 Points

Hi

You have the right idea, but you need to use parseInt(width) in your sum, so

 let totalWidth = totalImages * parseInt(width) ; 

At the moment in your example parseInt(width) isn't assigned to anything so the string value of width(190px) is still being used in the sum.