Skip to main content
🌱 Coding Level 1: First Steps 🌱

What's a Variable? πŸ“¦

A variable is a labeled box that holds a value so you can use it later.

We make a box with the word let, give it a name, and put something inside with =:

let score = 10;   // a box named "score" holding 10
let name = "Sam"; // a box named "name" holding "Sam"

Later, whenever you write score, the computer swaps in what's inside the box β€” 10.

You'll use boxes constantly: a score, a number of lives, a player's name… all of them live in variables. πŸ“¦

A variable is like:

After let lives = 3;, what is inside the box named lives?

The word let is used to: