Week 4 — Variables: Keeping Score¶
At a glance
| Date | Friday, September 4, 2026 |
| Unit | 1 — Think Like a Machine |
| Big idea | A variable is a named place where a program remembers a value that can change. |
| Goal | Students add score or health to an Arcade game and can explain what value is being remembered. |
| Student accounts needed | None. MakeCode autosaves in the browser. |
| Prep time | 5 minutes |
Why this lesson looks the way it does¶
Variables are easy to define and hard to feel. In a game, score makes them visible immediately: collect something, number changes, behavior changes. That is why this lesson avoids abstract variables like x and starts with score, lives, and speed.
The older students may already know the word variable. Push them past vocabulary into state: the program has to remember something between events. Younger students only need the sentence, "The game is keeping a number for me." Both are true.
CSTA 2026 standards¶
| Concept area | Connection |
|---|---|
| Algorithms & Design | Game rules can be planned around values that change over time |
| Programming | Variables store and update information while a program runs |
| Data & Analysis | Scores and counters are data generated by user actions |
| Systems & Security | Browser-saved projects and running games maintain state locally during use |
| Computing & Society | Many apps track changing values such as points, streaks, levels, and progress |
"I can…" objectives¶
By the end of today, students can say:
- I can describe a variable as a named value the program remembers.
- I can change the score when something happens.
- I can reset or display a value in my game.
- I can find a variable assignment in JavaScript.
Teacher prep — the 5-minute version¶
- Open https://arcade.makecode.com and a small project with a moving player.
- Be ready to demo a collectible and
change score by 1. - Write on the board:
Last Friday: Loops repeat
Today: Variables remember
Question: What should your game keep track of? - Prepare to say explicitly: no login, no account, use the same Chromebook if their project is there.
- Pair students cross-age; swap Driver/Navigator at 0:24.
Minute-by-minute run sheet¶
0:00–0:04 — Anchor¶
"Last Friday we used loops so the computer could do something again and again. Today we need the computer to remember what happened. If I collect five coins, the game has to know I have five — not just that I collected the last one. That remembered value is a variable."
Ask:
"Name a number a game remembers. Not just displays — remembers."
Take score, health, ammo, level, time, coins.
0:04–0:12 — Mini-lesson: score is memory¶
On the projector, make or open a moving player with one food/coin sprite. Add overlap if needed just for demo, or use a button event if you want to postpone collisions until Week 6:
on A button pressed→change score by 1- Then show a collectible version if students are ready.
Say:
"The number on the screen is not the important part. The important part is that the program has a place named score. When something happens, the value in that place changes. If I press A five times, the program is not remembering five button presses; it is remembering one number that changed five times."
Toggle to JavaScript and point to info.changeScoreBy(1) or let if visible.
"In text languages, variables often show up with names. The name matters because humans have to read it later.
scoreis better thanthingy."
0:12–0:36 — Paired build¶
Required build:
- Recreate or open a player that moves.
- Add one thing the game remembers: score, lives, speed, or coins.
- Change that value through an event or repeated action.
- Test by causing the value to change at least five times.
"Your job is to make the game remember one number and to be able to tell me exactly what changes it."
Driver/Navigator swap at 0:24.
"Swap. New Driver, your first task is to make the variable change by a different amount. Predict first, test second."
Tiered challenges¶
- 🟢 Starter (gr 5–6): Press A to add 1 point. Then change it so A adds 5 points.
- 🟡 Builder (gr 7–8): Add a collectible that increases score and then moves to a new random position.
- 🔴 Extender (gr 9–10): Toggle Blocks → JavaScript. Find where score changes. Add your own variable such as
coinsCollectedorplayerSpeed, change it in code, and explain why the name is better thanx.
Fast finishers
Ask: "Can you make score go up by 1 at first, then by 2 after the player reaches 10?" If they try it, they are already reaching toward next week's conditionals.
0:36–0:42 — Share-out¶
Choose one project with a clear score and one with a naming mistake or confusing value.
"What value does your game remember? What event changes it?"
If a student says "the score block," push once:
"Right — and what number is stored inside that score right now?"
0:42–0:45 — Teaser + prompt¶
"Next Friday the game starts making decisions: if score is high enough, do one thing; otherwise do something else. That is conditionals. The prompt is below — no writing, just noticing."
Share-out prompt¶
"What is one value your game remembers, and what causes that value to change?"
🤔 Think About This¶
Notice one number an app or game remembers about you this week: a streak, unread messages, battery percent, score, watch steps, video progress.
Ask: what action changes that number?
🔌 Unplugged Plan B — if the internet is down¶
Teach variables as named cups holding changing values.
| Time | Activity |
|---|---|
| 0:00–0:04 | Anchor: loops repeat; variables remember. |
| 0:04–0:12 | Cup variables. Put cups labeled score, lives, and speed on a table. Use counters or scraps of paper as values. Students physically add/remove counters as events happen. |
| 0:12–0:24 | Human arcade. One student is the player. Paper coins are on desks. Each coin collected adds one counter to the score cup. Touching a wall removes one from lives. |
| 0:24–0:34 | Pairs design their own two-variable paper game: choose names, starting values, and events that change them. |
| 0:34–0:41 | Groups trade games and play one minute. The test is whether the variable rules are clear enough for another group to run. |
| 0:41–0:45 | Teaser conditionals and Think About This. |
Do not let students say "the cup is the score." The cup is the variable; the counters are the current value.
Common problems & fixes¶
| Problem | Fix |
|---|---|
| Student says a variable is "a score" | Refine it: score is one example. A variable is any named value that can change. |
| Score changes too quickly | Check whether the change is inside a loop. If it is, the program may be scoring every interval instead of every event. |
| Student cannot make overlap work yet | Use A-button scoring today. Collisions get a full lesson in Week 6. |
| Extender creates variable but never uses it | Ask, "What event changes it? Where can the player see or feel it?" |
| Students lose work from prior week | Rebuild the tiny starter. No accounts means autosave is convenient, not guaranteed curriculum infrastructure. |
Vocabulary¶
- Variable — a named place where a program stores a value
- Value — the current information stored in a variable
- Score — a common game variable that tracks points
- Update — to change a stored value
- State — the remembered information that describes the program right now
Reflection — fill in after class¶
- Did students distinguish the variable name from the current value?
- Which students were ready for custom variables instead of built-in score?
- Did overlaps distract from the variable concept?
- What examples of real-life remembered numbers landed best?
Next week: Week 5 — Conditionals: Teaching a Program to Decide