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
Benoit Tordeurs
Full Stack JavaScript Techdegree Student 9,400 Pointsplease help
var width = '190px'; var numOfDivs = 10; var totalWidth =( 'parseInt(width)' * 'parseInt(numOfDivs)');
I can't multiply 10*190px, I use parseInt for the firt time, please help, thanks
1 Answer
Osaro Igbinovia
Full Stack JavaScript Techdegree Student 15,928 PointsHi Benoit, in JavaScript any thing(letter, number, word, sentence) in between quote marks(whether single or double) is a string. So enclosing 'parseInt(width)' and 'parseInt(numOfDivs)' within single quote marks has converted them to simple string of letters and you can't possibly multiply string of letters. All you need do is remove both of them from those single quote marks and you're good to go :)
var width = '190px';
var numOfDivs = 10;
var totalWidth = parseInt(width) * parseInt(numOfDivs) ;
And you really don't need to apply the parseInt() method on the 'numOfDivs' variable since a number(integer i.e. 10) is the value of the variable. You only need to apply the parseInt() method when you want to extract a number from a string e.g. '359horses'.
Benoit Tordeurs
Full Stack JavaScript Techdegree Student 9,400 PointsBenoit Tordeurs
Full Stack JavaScript Techdegree Student 9,400 PointsSo many thanks it was so good, I really appreciated and the comment,good day.