Variables: let, const, var

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Variables: let, const, var

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Can a variable declared with let be reassigned later?
A Yes
B No
2. Can a variable declared with const be reassigned later?
A No
B Yes
3. Is 'var' the modern, preferred way to declare variables?
A Yes
B No
4. Does 'let count = 5;' declare a variable named count?
A No
B Yes
5. Can you redeclare the same variable name with let twice?
A No
B Yes

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1let age = 12; Avar total = 100;
2const name = "Sam"; Bconst
3The older, less preferred way to declare variables CWrong - the keyword 'let' must be lowercase
4Signals to other developers that a value is fixed DDeclares a variable that can never be reassigned
5const pi = 3.14; pi = 3.15; EDeclares a variable that can change later
6LET score = 0; FWrong - const variables can't be reassigned

Definitions

let

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
___ age = 12
2.
_____ name = "Sam"
3.
let score = 0; score = score _ 1
4.
___ total = 100
5.
_____ pi = 3.14

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A let age = 12;
B cnst name = "Sam";
C age = 13;
Question 2
A const pi = 3.14;
B let score = 0;
C score = score + 1;
D let count = 5;
E pi = 3.15;
Question 3
A LET total = 10;
B let count = 5;
C count = 6;
Question 4
A var oldWay = 1;
B let modernWay = 2;
C const modernWay = 3;
Question 5
A const name = "Sam";
B let age = 12;
C age == 13;

Answer Key

Variables: let, const, var
Section A: Quick Questions
Q1
A — Yes
Q2
A — No
Q3
B — No
Q4
B — Yes
Q5
A — No
Section B: Match the Pairs
Q1
let age = 12; → Declares a variable that can change later
Q2
const name = "Sam"; → Declares a variable that can never be reassigned
Q3
The older, less preferred way to declare variables → var total = 100;
Q4
Signals to other developers that a value is fixed → const
Q5
const pi = 3.14; pi = 3.15; → Wrong - const variables can't be reassigned
Q6
LET score = 0; → Wrong - the keyword 'let' must be lowercase
Section C: Definitions
Q1
let — Declares a variable whose value can be changed later.
Section D: Fill in the Blanks
Q1
let age = 12
Q2
const name = "Sam"
Q3
let score = 0; score = score + 1
Q4
var total = 100
Q5
const pi = 3.14
Section E: Spot the Error
Q1
B — 'const' is misspelled as 'cnst'.
Q2
E — const values cannot be reassigned after they're set.
Q3
A — 'let' must be lowercase - a capital L causes an error.
Q4
C — You can't redeclare 'modernWay' - it's already declared with let.
Q5
C — Assignment uses a single =, not the comparison operator ==.