JS Built-ins
Operatorsbeginner

Operators β€” compound assignment: +=, -=, *=, /=

Compound assignment operators

x += 5 is shorthand for x = x + 5. Applies to -=, *=, /=, %=, **=.

Challenge: Write compoundAssignment(x) that:

  1. Does x += 10
  2. Then x -= 3
  3. Then x *= 2
  4. Then x /= 2
  5. Returns x
πŸ’‘ Hints (1)
  • β€’ Work through: (x+10-3)*2/2 = x+7