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

Solution to Numbers and Strings challenge

Hi, what is the solution to the Numbers and Strings challenge. I have tried the following, but get a syntax error Paser error:

var totalWidth = parseInt(width) x numOfDivs;

2 Answers

hello sperera your syntax is right but you are not using the multiply operator. it looks like you are using x instead of *

// you wrote
var totalWidth = parseInt(width) x numOfDivs;

but it should be

var totalWidth = parseInt(width) * numOfDivs;

i hope this solves you problem

oh my goodness.. yes! thanks a lot!

No, that does not solve it. These are the variables used to calculate the totalWidth:

var width = '190px'; var numOfDivs = 10;

So parseInt is required to change the width from string to int.

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

I see, I presumed you already declared a width variable that held a integer from using the parseInt method. I didn't see the video.