pxt-core-own
Version:
Microsoft MakeCode, also known as Programming Experience Toolkit (PXT), provides Blocks / JavaScript tools and editors
36 lines (26 loc) • 989 B
Markdown
# Assignment operator (=)
Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/types/number),
[string](/types/string), or [boolean](/types/boolean) you say.
```block
let myNumber = 7
let myString = "Yellow Whirled"
let myLogic = true
```
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*. A value can be a _literal_
value, like `20` or `"Dreaming"`. Or, a value can be another variable you want
to copy, ```let newItem = oldItem```.
Here is an example of variable assignment in code:
```typescript
let perfect = 10;
let extra = 1;
let extraPerfect = perfect + extra;
```
## ~hint
You can use the assignment operator with variables of
every [type](/types). A *type* is which kind of thing
a variable can store, like a number or string.
## ~
## #examples
## See also
[Variables](/blocks/variables/var), [Change operator](/blocks/variables/change)