The big ideaA variable can count. Each time, it takes its old value and adds one.
How it works
A variable can count. Each time, it takes its old value and adds one.
A counter starts at zero. The new value is the old value plus one.
A rule that puts 1 in the box every time is a bug. It forgets what was in the box, so it always gives one.
Between players, put zero back in the box, so everyone starts fresh.
Two rules, three stars.
Example 1: The bug
Tavi's rule says: put 1 in the box called stars.
The first star lands, and the screen shows 1.
A second star lands, but the screen still shows 1. The rule forgets what was in the box.
Example 2: The fix
Take the old value out of the box, add one, and put the new value back.
The box holds 2, so 2 + 1 = 3.
The box now holds 3.
Example 3: Counting up
The box starts at 0.
The first star: 0 + 1 = 1. The second star: 1 + 1 = 2. The third star: 2 + 1 = 3.
The screen counts up, one, then two, then three.
Example 4: A new player
Between players, Mina puts 0 in the box called stars.
The next player's first star: 0 + 1 = 1.
Everyone starts fresh.
Words to know
variable
A box with a name that holds a value.
counter
A variable that counts up.
old value
What is in the box before the star lands.
new value
The old value plus one.
Watch out
Putting 1 in the box every time never counts up. It forgets the old value.
Putting 0 in the box every time keeps it at zero.
Emptying the box each time loses the count.
A bug is fine. We find it, fix the rule and try again.
Try it
The box holds 4 and the fixed rule adds one. What does it hold now?
The rule put 1 in stars runs three times. What does the box hold?
What number does a counter start at?
The box holds 2, and we add three. What does it hold?
Answers: 1. 5 · 2. 1 · 3. Zero · 4. 5
Try at homeWrite zero on a paper. Each time you do a jump, cross out the number and write the old number plus one. After ten jumps, say what the variable holds. Then try the bug: write one every time, and see what happens.
For grown-upsPlay the Mission: write zero on a paper. Each time your child does a jump, they cross out the number and write the old number plus one. After ten jumps, ask what the variable holds. Then try the bug: write one every time, and see what happens.
Open these notes on screenScan the code, or go to tutorpip.com.