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

Why is var ten not equal to 10?

I am not sure why this code isn't going through... Any thoughts?

index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>JavaScript Foundations: Operators</title>
    <link rel="stylesheet" href="core.css">
    <script>
      var a = 1,
          b = 2,
          c = 4,
          three = c-a,
          ten = 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;
      Or:
      var seven = a + a + a + a + a + a + a;
      But that's kinda lame. Good luck! */



    </script>
  </head>
  <body>
    <h1>JavaScript Foundations</h1>
    <h2>Operators</h2>
    <script src="viewer.js"></script>
  </body>
</html>

You have to call it in order to see the result.

Try console.log(ten) or alert(ten).

2 Answers

Your code is correct for var ten to be equal to 10, the problem seems to be with how treehouse evaluates your answer. Try assigning 'three' and 'ten' individually:

  var a = 1,
      b = 2,
      c = 4;
  var three = c-a;
  var ten = c*b + b;

The above worked for me.

Thanks, Michael, this worked!