LESSON 3
Variables
Learning objective: Store and reuse data with variables.
Understand
Variables are named containers for values.
Declare variables with let for values that can change. A variable has a name and holds a value you can read and update later. Use clear, descriptive names.
Analogy: A variable is like a labelled jar you can put something into and take it out later.
See It in Action
Declaring and updating:
let score = 0;
score = score + 10;
console.log(score); // 10How it works:
score starts at 0, then is reassigned to 10; console.log prints its current value.Try It Yourself
- Create a
letvariable for your name. - Log it to the console.
- Reassign it and log again.
Quick Quiz
Which keyword declares a variable that can change?
Challenge
Track a running total in a variable and log the result.
Success condition: Your variable stores a value and logs an updated result.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →