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

How to create a variable "three"

If we can only use the variables a, b and c, how do we make a variable named 'three'?

<!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 = 3;

      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>

1 Answer

Hugo Paz
Hugo Paz
15,622 Points

Hi Lindsey,

The challenge objective is to use the existing values in the a, b ,c variables to set the value on the variables you are going to create.

So if they ask you to create a variable 'five' with the value of 5 you do:

var five = a + c;