Aim of the puzzle: Use the
-- operators to change the value of a variable.
Walk through of solution: On the first line, the
x variable is defined with the value 5. The next line increments (adds 1 to) the
x variable. You can see the results printed by the next line.
Now, tap on the
x on the next line all by itself. Tap the
-- button to decrement (subtract 1 from) the
x variable. When you run the code now you will see that the value of
x went back down by 1.
Sample code solution:
(Tap below to reveal)
let x = 5; x++; print('x is ' + x); x--; print('x is now ' + x);
let), Increment (
++), Decrement (