Setting a variable using the Toolbox
In the ||variables:Variables||
category of the Toolbox you can create or choose a variable to assign:
Use an equals sign to make a variable store a number, string, or other type of value.
When you use the equals sign (=) to store something in a variable, the equals sign is called an assignment operator, and what you store is called a value.
When you work in JavaScript or Python the equals sign is used:
item = 3
In blocks, a variable assignment happens with the ||variables:set||
block when you set a value to a variable.
let item = 3
In the ||variables:Variables||
category of the Toolbox you can create or choose a variable to assign:
This program makes the variable item
equal 5
and then shows it on the LED screen.
let item = 5
basic.showNumber(item)
This program makes the variable name
equal Joe
and then shows it on the LED screen.
let name = "Joe"
basic.showString(name);
You can use the assignment operator with variables of every type. A type is which kind of thing a variable can store, like a number or string.