[SOLVED] Compound Assignment With Augmented Addition (Help needed)

Tell us what’s happening:
I’m so stuck on this, I really don’t know what to do

Your code so far

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

// Only modify code below this line

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


**Link to the challenge:**
https://www.freecodecamp.org/challenges/compound-assignment-with-augmented-addition

You’re gonna use the compound assignment operator += to add a number to a variable and assign it at the same time.

If you have

a = a + 42;

you can use += as a shorter version:

a += 42;

Thank You so much, do you also know how to do the subtraction bit? I’m confused
var a = 11;
var b = 9;
var c = 3;

// Only modify code below this line

a -= a - 6;
b -= b - 15;
c -= c - 1;
that’s what I have so far

It’s also the same idea/pattern with subtraction (and in general, operations that require two operands).

Is it the same for Multiplication and Division or is it another concept?

Yep. Totally the same :wink:

I’m really confused :frowning:

Can you tell what exactly confuses you?

This is what I came up with, for the multiplication

var a = 5;
var b = 12;
var c = 4.6;

// Only modify code below this line

a *= 25;
b *= 36;
c *= 46;

What am I doing wrong?

I’m very confused, I thought what I was doing was making it right

Thanks, I got how to do it. I really appreciate your help

The pattern of operating on a variable and assigning it back to that variable is so common that there’s a short-hand way of writing it.

Instead of writing a = a + 3 you can just write a += 3. Same for all the other arithmetic operators. It’s just a different way of writing the same thing, but you only need to refer to the named variable once.

Thanks, I got the hang of it now :smiley: