Compound Assignment With Augmented Addition
In programming, it is common to use assignments to modify the contents of a variable. Remember that everything to the right of the equals sign is evaluated first, so we can say:
myVar = myVar + 5;
myVar . Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step.
One such operator is the
let myVar = 1;
myVar += 5;
6 would be displayed in the console.
Convert the assignments for
b , and
c to use the
let a = 3;
let b = 17;
let c = 12;
// Only change code below this line
this is my answer below, still, I’m getting error message,
a += 15;
b += 26;
c += 19;
It helps if you can provide a link to the challenge you are working on.
thank you, i just updated the post with the link
where do these numbers come from? the original code didn’t have these numbers, so you have changed the calculation and the result
this the original:
a = a + 12;
b = 9 + b;
c = c + 7;
you need to write that in a different way, but it needs to do the same exact thing
they’re coming from the actual link where it says to replace the letters with the numbers
Nowhere does it say that. It says that after correctly converting to this syntax, the stored values should still be the same.
yeah that’s what i meant, you’re replacing the letters with the numbers on the top of the equation to get the numbers in the link as the solution
…no… The instructions want you to change zero numbers. The instructions want you to use the exact same numbers but with the compound assignment syntax instead of the current syntax.
i know that. i’m saying you’re changing the letters to the numbers above. as in a is changed to 3 and then it equals 15, that’s how 15 came up
And I am saying that nowhere in the challenge link do the instructions say to use those numbers.
This just is not true.
a is initialized to
12 added to its value. At no point should
15 be added into the value stored in
a. The challenge only wants users to change the syntax that is used to add
12 to the initial value of
i know that, i never said 15 is added into it. im saying you get 15 when you change A to 3
i wasn’t giving him an answer i was simply responding to where the numbers are coming from, the person above asked where he is getting those numbers from and i responded that they’re coming from the link itself where it says that the code needs to equal 15, 26, and 19.
That wasn’t clear (to me at least) from your first post.
I’m not sure why this was an important thing to necro this thread for? It doesn’t help fix the issue OP was having at all.