What is the solution to the exercise: Compound Assignment With Augmented Addition for Javascript

What is the solution to the exercise: Compound Assignment With Augmented Addition for Javascript
0

#1

Can’t seem to figure this out.


#2

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

// Only modify code below this line

a += a + 9;
b += b + -8;
c += c + -5;


#3

I think your code gives the correct values for a, b, and c, but what there looking for is simpler than what you have. For example, just increase a by 12, rather than increasing a by (a + 9). One of the big ideas with the “+=” notation is to avoid having your variable appear on the right side of the “+=”.


#4

Then, it probably should be:

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


#5

Sorry, it should be:

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


#6

It says to Convert the assignments for a, b, and c to use the += operator. then below in the checklist section it mentions---- a should equal 15
b should equal 26
c should equal 19

Hence sollution

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

// Only modify code below this line

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


#7

I need help, because I have the following error and I do not know how to overcome this problem being a bug …

My code

var a = 11;
var b = 9;
var c = 3;

// Only modify code below this line

a = a -- 6;
b = b -- 15;
c = c -- 1;


#8

To subtract a value from an existing variable and assign the result back to the existing variable, you simple use the -= operator.