How do I solve compound assignment with augmented addition?

Tell us what’s happening:
How do i convert the assignments for a , b , and c to use the += operator for the code below?

Your code so far


var a = 3;
var b = 17;
var 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/86.0.4240.183 Safari/537.36.

Challenge: Compound Assignment With Augmented Addition

Link to the challenge:

the += operator is a short hand way of writing addition

so if yoo want to add 4 to sum you could write sum = sum + 4 but also in a shorter way sum += 4

1 Like

This is the solution I made:

var a = 3;

var b = 17;

var c = 12;

// Only change code below this line

a += 12;

b += 9;

c += 7;

above we have defined variables and its 1st values.

Below, we define the second value of the variables with the help of the “+ =” operator and add the 1st and 2nd values to the variable we have defined.

sorry for my bad english.

1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

1 Like