Doesn't make any sense. Logic is flawed lol

Ok, this states the following:

In programming, it is common to use assignments to modify the contents of a variable. Remember that everything to the right of the equals sign is evaluated first, so we can say:

myVar = myVar + 5;

to add 5 to myVar . Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step.

One such operator is the += operator.

That means that you’re adding 1 and it is also equal to 5? if it is 5, how can it equal 6? i’m confused lol

Your code so far


let a = 3;
let b = 17;
let c = 12;

// Only change code below this line
a = a + 12;
b = 9 + b;
c = c + 7;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36

Challenge: Compound Assignment With Augmented Addition

Link to the challenge:

myVariable += 5 means "take the current value stored in myVariable, add 5, and save the result to myVariable. It means the exact same thing as myVariable = myVariable + 5.

1 Like

wow I feel dumb lol. thanks so much

It takes time to get used to all this stuff

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.