javascript · level 1 · unit 2 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
A is a box with a name on it.
A variable is like a box with a label. You put something in the box, write a name on the label, and from then on you say the name to get it back.
makes a new box. In let name = "Sam"; the label is name, and the = puts "Sam" inside. Whatever is inside the box is called its .
To get the value back, use the name with no quotes, like console.log(name);. Spell it the same way every time, or JavaScript gives you a ReferenceError.
let name = "Sam";
console.log(name); Read the = as “put into”, not “equals”.
guess first
Quotes or no quotes? Guess what this shows.
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
let pet = "Biscuit";
console.log(pet);
console.log("pet");
your turn
Your turn. Put your name in the box.
Type your name between the quotes on line 1, then press run. Both lines use the same box.
fix it
Where did the popcorn go? Can you fix it?
- It is a ReferenceError, so JavaScript met a name it does not know. Look inside the brackets on line 2.
- Two letters are swapped. The box on line 1 is called snack.
- Change snakc to snack, then press run.
nailed it
you made the computer remember. :D
- A variable is a box with a name on it.
letmakes the box and=puts a value in.- Spell the name the same way every time.
new words in your collection
- variable
- value
- let
This lesson isn’t saved. A free account remembers every lesson you finish.