Aim of the puzzle: Use the ++
and --
operators to change the value of a variable.
Walk through of solution: On the first line, the y
variable is defined with the value 5. The next line increments (adds 1 to) the y
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 y
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 y = 5;
y++;
print('y is ' + y);
y--;
print('y is now ' + y);
Javascript Concepts: Variables (let
), Increment (++
), Decrement (--
)
Grasshopper Concepts: print()