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 Foundations Numbers Operators

Cant make a variable named and assign the correct 100 number.

A queston is Create a variable named "onehundred" and assign the correct numeric value 100 to it using only variables a, b, and c and the common numeric operators?

I cant make the number 100 after created the variable of ten. I do not want to repeat making other the variables because its already exist the ten variable I was thought using the ten * ten. Why does not work that ways?

var three = a + b;
      var ten = b + b * c;
      var nineteen = c * c + b + a;
      var onehundred = ten * ten;

and I tried

var onehundred = (ten) * (ten); 

2 Answers

Damien Watson
Damien Watson
27,419 Points

Hi Brian, The question is asking for the value of 100 by using only (a, b or c), so add and multiply to get this response. You already have what ten is, so multiply it by itself (use brackets to separate)

var ten = b + b * c;
var onehundred = (b + b * c) * (b + b * c);

I know what you're saying about already having defined 'ten', but I think the point of the exercise is getting to know the operators. :)

Damien Watson correct, thanks for answered , Is possible in javascript using the variable 'ten' become the value of 100? My question is can do like this

var onehundred = ten * ten;
Damien Watson
Damien Watson
27,419 Points

Absolutely, just not in the treehouse test ;)