37 lines
935 B
Markdown
Raw Normal View History

2016-03-25 16:47:20 -07:00
# Assignment Operator
2017-03-16 07:57:41 -07:00
Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/types/number)
or [string](/types/string) you say.
2016-03-25 16:47:20 -07:00
2016-05-24 15:36:04 -07:00
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*.
2016-03-25 16:47:20 -07:00
## Storing numbers in variables
2016-05-24 15:36:04 -07:00
This program makes the variable `item` equal `5` and then shows it on the [LED screen](/device/screen).
2016-03-25 16:47:20 -07:00
````blocks
2016-05-24 15:36:04 -07:00
let item = 5
basic.showNumber(item)
2016-03-25 16:47:20 -07:00
````
## Storing strings in variables
2016-03-25 16:47:20 -07:00
2016-05-24 15:36:04 -07:00
This program makes the variable `name` equal `Joe` and then shows it on the [LED screen](/device/screen).
2016-03-25 16:47:20 -07:00
````blocks
2016-05-24 15:36:04 -07:00
let name = "Joe"
basic.showString(name);
2016-03-25 16:47:20 -07:00
````
## Notes
2016-03-25 16:47:20 -07:00
2016-05-24 15:36:04 -07:00
You can use the assignment operator with variables of
2017-03-16 07:57:41 -07:00
every [type](/types). A *type* is which kind of thing
2016-05-24 15:36:04 -07:00
a variable can store, like a number or string.
2016-03-25 16:47:20 -07:00
## See also
2016-03-25 16:47:20 -07:00
2017-03-16 07:57:41 -07:00
[variable](/blocks/variables/var), [types](/types)
2016-03-25 16:47:20 -07:00