Variables: let, const, var, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
Variables: let, const, var in one minute
What students need to know
var is the original keyword, now mostly replaced by let/const. Using const shows the value is meant to stay the same.
let creates a variable whose value can change. const locks the value so it can't be changed.
Mistakes students make
- 'const' is misspelled as 'cnst'.
- const values cannot be reassigned after they're set.
- 'let' must be lowercase - a capital L causes an error.
- You can't redeclare 'modernWay' - it's already declared with let.
PREVIOUS · MODULE 2Comments
YOU ARE HERE · MODULE 3Variables: let, const, var
NEXT · MODULE 4Basic Data Types
What students will learn in this module
Every question in Module 3
Quick questions
- Can a variable declared with let be reassigned later?AYesBNo
- Can a variable declared with const be reassigned later?ANoBYes
- Is 'var' the modern, preferred way to declare variables?AYesBNo
- Does 'let count = 5;' declare a variable named count?ANoBYes
- Can you redeclare the same variable name with let twice?ANoBYes
Key terms
Students type the meaning of:
let
Match the pairs
let age = 12;Match it to what it doesconst name = "Sam";Match it to what it doesThe older, less preferred way to declare variablesMatch it to what it doesSignals to other developers that a value is fixedMatch it to what it doesconst pi = 3.14; pi = 3.15;Match it to what it doesLET score = 0;Match it to what it doesFill in the blanks
___ age = 12
Hint: Type the keyword used to declare a variable that can change.
_____ name = "Sam"
Hint: Type the keyword used to declare a variable that never changes.
let score = 0; score = score _ 1
Hint: Type the operator used to add to the score.
___ total = 100
Hint: Type the older keyword used to declare a variable.
_____ pi = 3.14
Hint: Type the keyword used to declare a variable that never changes.
Spot the error
Question 1
Alet age = 12;Bcnst name = "Sam";Cage = 13;
Question 2
Aconst pi = 3.14;Blet score = 0;Cscore = score + 1;Dlet count = 5;Epi = 3.15;
Question 3
ALET total = 10;Blet count = 5;Ccount = 6;
Question 4
Avar oldWay = 1;Blet modernWay = 2;Cconst modernWay = 3;
Question 5
Aconst name = "Sam";Blet age = 12;Cage == 13;
