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.
- Initialize a variable
totalto theinitialValue. - Use
+=to addamountToAddtototal. - Use
+=to add the string " USD" to the updatedtotal. - Return the final string.
01EXAMPLE 1
Input
initialValue = 100, amountToAdd = 50Output
"150 USD"Explanation: Accumulates value then appends units.
Constraints
- Use the += operator.
- Final result must be a formatted string.
FundamentalsVariablesOperators
JavaScriptSystem handles I/O — write your function only
Loading...
9 Hidden
Input Arguments
initialValue100
amountToAdd50
Expected Output
150 USD
Click RUN to test your solution