Challenge - 5 Problems
Assignment Operator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this code using += operator?
Consider the following JavaScript code snippet. What will be printed to the console?
Javascript
let x = 5; x += 3; console.log(x);
Attempts:
2 left
💡 Hint
Remember that += adds the right value to the left variable.
✗ Incorrect
The += operator adds the right value (3) to the left variable (5), so x becomes 8.
❓ Predict Output
intermediate2:00remaining
What is the output after using *= operator?
Look at this code. What will be the value of y after execution?
Javascript
let y = 4; y *= 2; console.log(y);
Attempts:
2 left
💡 Hint
The *= operator multiplies the variable by the right value.
✗ Incorrect
y starts at 4, then y *= 2 multiplies it by 2, so y becomes 8.
❓ Predict Output
advanced2:00remaining
What is the output of this code using combined operators?
What will be printed to the console after running this code?
Javascript
let a = 10; a -= 3; a /= 7; console.log(a.toFixed(2));
Attempts:
2 left
💡 Hint
Apply each operator step by step and then format the number.
✗ Incorrect
a starts at 10, a -= 3 makes it 7, then a /= 7 makes it 1. toFixed(2) formats it as '1.00'.
❓ Predict Output
advanced2:00remaining
What is the output of this code using %= operator?
What will be the value of b after this code runs?
Javascript
let b = 15; b %= 4; console.log(b);
Attempts:
2 left
💡 Hint
The %= operator gives the remainder of division.
✗ Incorrect
15 divided by 4 leaves a remainder of 3, so b becomes 3.
❓ Predict Output
expert3:00remaining
What is the output of this tricky assignment code?
What will be printed to the console after running this code?
Javascript
let c = 2; let d = 3; c *= d += 4; console.log(c);
Attempts:
2 left
💡 Hint
Remember that d += 4 happens first, then c *= d.
✗ Incorrect
d += 4 makes d = 7, then c *= 7 makes c = 14.