You can use the change operator with variables of each of the supported types.
Change value
Change, meaning increase, the value of a variable by some amount.
let x = 0
x += 2
The change blocks increase the value in the variable by the amount you want. This is also known as an addition assignment operation.
Change a declared variable
Use the change operator to set a new, larger value to a variable.
If you let
a variable have a value of 1
, the change block makes the value change
by 2
like this:
let x = 1
x += 2
Example: show the value of a variable
Use the assignment operator to set the value of a variable. Change the value of a variable from 0 to 1 using the change item block. Then display the new value of the variable on the LED screen. Like this:
let x = 0;
x += 1;
basic.showNumber(x);