Lesson 1 of 8
A box with a name on it
Show on a big screenA game must count mangoes. It needs a place to keep the number.
Step 1 of 4
- An empty box. No name yet.
- Name it
score. - Set
scoreto 5. That puts 5 in the box. - Set
scoreto 9. The 5 is gone.
A variable is a named box. It holds a value. In this track, values are numbers.
You pick the name: score, lives, mangoes. Blocks use the name to find the box. Lives are the chances a player has left. The computer does not know what the name means.
Rule: A variable is a named box. It holds one value at a time. Setting it replaces what was there.
Make score hold 5 and lives hold 2. Tap the buttons in any order.
Loading lab…
Try the lab to finish this lesson.