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

Yusuf Salaam
Yusuf Salaam
1,748 Points

Operator challenge

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.

Ive tried everything could possibly think of what do i do

Hi Yusuf,

Can you post one attempt that you've tried? Somebody can help with where you might be going wrong.

I'm assuming you understand the concept of what they want if you've made it this far into the challenge.

There are many correct answers here.

5 Answers

Jason Wiram
Jason Wiram
42,762 Points

Hi Yusuf. Using the supplied variables:

var a = 1, b = 2, c = 4;

Here are potential answers for the first three tasks. If you understand these, all that is left is determining what math will get you to 100.

 var three = c - a;
 var ten = (b * c) + b;
 var nineteen = (c * c) + c - a;
 var onehundred = ???

As mentioned above, posting your attempted code greatly helps us understand where things might be going wrong. Keep trying!

Andrew Pham
Andrew Pham
3,492 Points

You may need to tell us what the variables a, b and c are storing

Hi Andrew,

That's in the code challenge that is linked to on the right.

Yusuf Salaam
Yusuf Salaam
1,748 Points

These are the numbers that i have to use. var a = 1, b = 2, c = 4;

Are you having trouble with the math part of this and how to get to 100 with those numbers or do you need help with how to use the different operators?

Can you post one of your attempts?

var a = 1, b = 2, c = 4; var three = c - a; var ten = (b * c) + b;
var nineteen = (c * c) + c - a; var onehundred = (a+b+c)*(a+b+c)*b+b;

Yusuf Salaam
Yusuf Salaam
1,748 Points

Thank you all for your help with my questions!