JavaScript JavaScript Numbers Working with Numbers Numbers and Strings

Kevin Leong
Kevin Leong
1,636 Points

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
79,061 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.