Compound Assignment

EasyAcc. 93.5%
+25 XP 8

Buffer Updates

Shorthand operators like += allow you to update a variable's value based on its current state with minimal code.

  1. Initialize a variable total to the initialValue.
  2. Use += to add amountToAdd to total.
  3. Use += to add the string " USD" to the updated total.
  4. Return the final string.

01EXAMPLE 1

InputinitialValue = 100, amountToAdd = 50
Output"150 USD"

Explanation: Accumulates value then appends units.

Constraints

  • Use the += operator.
  • Final result must be a formatted string.
FundamentalsVariablesOperators
JavaScript
Loading...
9 Hidden

Input Arguments

initialValue100
amountToAdd50

Expected Output

150 USD

Click RUN to test your solution