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

Muhammad Haris Khan
Muhammad Haris Khan
8,587 Points

Can not seem to figure it out, why it is not adding to 100?

Why is this not adding to 100 = 64+32+2+2 = 100 or not?

<!DOCTYPE html>
<html lang="en">
    <title>JavaScript Foundations: Operators</title>
    <link rel="stylesheet" href="core.css">
      var a = 1,
          b = 2,
          c = 4;
      var three = a+b;
      var ten = c+c+b;
      var nineteen = (c*c)+ c - a;
      var onehundred = (c*c*c)+ (C*b*C) +b+b;
      Common operators used in numeric calculations:
            addition: +
         subtraction: -
      multiplication: *
            division: /
             modulus: %
            grouping: ()

      Your tasks in this code challenge will consist of
      creating variables and assigning correct values to
      them using only variables a, b, and c and the above
      operators. For example, if the task is "Create a
      variable named "seven" and assign the correct
      numeric value 7 to it using only variables a, b,
      and c and the common numeric operators." then one
      possible solution would be:
      var seven = a + b + c;
      Another solution could be:
      var seven = (b * c) - a;
      var seven = a + a + a + a + a + a + a;
      But that's kinda lame. Good luck! */

    <h1>JavaScript Foundations</h1>
    <script src="viewer.js"></script>
Stephen Little
Stephen Little
8,312 Points

Not sure I ran the code in the console on Chrome and it game me the right numbers. Sorry not sure what else could be wrong ;(

4 Answers

Justin Horner
Justin Horner
Treehouse Guest Teacher

Hello Muhammad,

It looks like the issue is the use of an undeclared variable capital C instead of your lower-case c variable on the following line.

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

Try changing them to your lower-case variable.

I hope this helps.

Stephen Little
Stephen Little
8,312 Points

You used Capital C in one line of code it should be all lower case letting in your line of code to get the result of 100

Cheers! Stephen

Muhammad Haris Khan
Muhammad Haris Khan
8,587 Points

this is such a silly mistake, thanks for help

cant make it for 100 if I put like this

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