Compound Assignment With Augmented Addition Fails

Tell us what’s happening:
a should equal 15
b should equal 26
c should equal 19
You should use the += operator for each variable

Your code so far


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

// Only modify code below this line

a += 12;
9 += b;
c += 7;

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition

9 += b;
You can’t do this. This is trying to change the value of the number 9 to 26.

1 Like

I know this post is older, but I felt the need to comment . . .wasn’t this person trying to change the value of B to 26 by typing the syntax backwards . . 9 += b. .?

Even if that is what they were trying to do the = assignment operator works assigning what is to the right of it to the left of it. += is a shorthand to avoid writing num = num + 3 and just write num += 3

Backward syntax doesn’t exist, so, 9 += b means 9 = 9 + b, which is not something that can be done.

Ok. That’s probably simpler = can’t be done. TY! :wink: