Tell us what’s happening:

I don’t know what I’m doing wrong in this problem? Can someone point out my mistake?

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

// Only modify code below this line
a = a + 12;
a += 3; // Now, 'a' is equal to 15
b = 9 + b;
b += 17; // Now, 'b' is equal to 26
c = c + 7;
c += 12; // Now, 'c' is equal to 19
``````

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

// Only modify code below this line
a = a + 12;
a += 3; // Now, ‘a’ is equal to 15
b = 9 + b;
b += 17; // Now, ‘b’ is equal to 26
c = c + 7;
c += 12; // Now, ‘c’ is equal to 19

Remove all the previous lines first, and then do the challenge, the first answer would be:

a += 12 (because original value of a is 3 and a += 12 means a = a(3) + 12 = 15)
b += 9 (because original value of b is 17 and b += 9 means b = b(17) + 9 = 26)
c += 7 (because original value of c is 12 and c += 7 means c = c(12) + 7 = 19)

This is nothing like the example provided or the hint. How was I supposed to know to put this?

1 Like

They wanted you to modify those lines using the shorthand of a = a + number to a += number.

If you wouldn’t modify their provided lines, the a is already 15 (and they wanted you to make it 15) and b was already 26 and c was already 19. How would you use Augmented Addition shorthand then?

This is what I am confused about. how to do augmented addition shorthand. is there like a lesson I can learn these skills or is it only the practice problems with examples?

I’m also learning from their Curriculum though, but I’ve reached to Object Oriented Programming section and there is no such explanation since it’s pretty straightforward.

x += y is just the shorthand of (x = x + y) just like they stated in that challenge. But you can get more details from the link below:

`https://www.w3schools.com/js/js_operators.asp`

Good luck!

how can x+y=x
That is impossible

`x = x + y`, not `x + y = x`.

`x` is the name of a variable. You’re saying "assign the current value of `x` + the value of `y` to `x`. You’re assigning a new value to `x`.

`=` is an operator that means assign, not equals. This isn’t maths. `x = 1` means “assign the value 1 to the variable `x`" not "`x` equals 1”

``````// Assign the value 1 to the variable x:
var x = 1;
// Assign the value 2 to the variable y:
var y = 2;

// Assign a new value to x:
x = 3

// Assign a new value to x:
x = x + y
// x was 3, and y is 2, so x is now 5
``````
1 Like

This was a great explanation