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 trialYusuf Salaam
1,748 PointsOperator 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
5 Answers
Jason Wiram
42,762 PointsHi 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
3,492 PointsYou may need to tell us what the variables a, b and c are storing
Jason Anello
Courses Plus Student 94,610 PointsHi Andrew,
That's in the code challenge that is linked to on the right.
Yusuf Salaam
1,748 PointsThese are the numbers that i have to use. var a = 1, b = 2, c = 4;
Jason Anello
Courses Plus Student 94,610 PointsAre 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?
ilyass mougar
Courses Plus Student 2,858 Pointsvar 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
1,748 PointsThank you all for your help with my questions!
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi 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.