πŸ“¦ Variables for Kids

A variable is just a labeled box that holds something.

Boxes with Labels

Imagine a box. You write "favoriteColor" on the side. Inside the box, you put a piece of paper that says "blue." Later you can:

  • Look in the box and see "blue."
  • Throw out the paper and put in a new one that says "purple."
  • Move the box around.

That's a variable. The box is the variable. The label is the variable's name. The paper is the value.

Why Labels?

If your room had 50 unlabeled boxes, you'd never find anything. Code is the same β€” labels (names) help you keep track.

Picking a Good Name

"thing" is a bad name. "favoriteColor" is a great name. Be specific. Future-you will thank past-you.

🎯
Try this!

Now you try! Imagine a variable called petName. What value would you put in it?

πŸ‘¨β€πŸ‘©β€πŸ‘§
For grown-ups

Parent/teacher tip: Boxes-with-labels is the classic mental model. Reinforce that the label and the contents are separate things.