Tell us what’s happening:
I completed the section initializing variables a, b, and c without problem. What I don’t understand is the code under // Do not change code below this line.
How does a = a + 1 work? or b = b + 5? I’m interpreting it as a math equation (“a” could not equal “a + 1”). What is this for and what am I missing?
Your code so far
// Initialize these three variables
var a = 5;
var b = 10;
var c = "I am a";
// Do not change code below this line
a = a + 1;
b = b + 5;
c = c + " String!";
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.
The var a = 7; returns a value of 7.
a = a + 1; would return 8 because the code is telling the computer to complete the equation a + 1 and assign the new value to a.
a === a + 1; says the value is expressly 8, which is false because it was initialized at 7.
a = a === a + 1; still false. you are just making a false statement equal the var a.
This is a bit of extra-credit because it requires you to understand associativity. The assignment operator is right-associative, meaning that everything on the right of the = is evaluated before it is assigned to the variable.