← ACARA Digital Technologies Years 7–8

Reassigning a let variable

Reassigns an existing let variable. The right side is worked out first using the old value, then the new value replaces it. Don't write let again.

Understanding Reassigning a let variable in ACARA Digital Technologies Years 7–8

What it does: The first line declares lives with let. The second line reassigns it without let, so lives is now 2. score + 2 is worked out as 5 + 2 = 7, and then 7 replaces the old value of score. The variable already exists, so you just write score = 10; with no let. Writing let again would cause a SyntaxError. The computer works out score + 1 as 4 + 1 = 5 first, then stores 5 back in score. let is only used the first time, when you create the variable. After that, just use name = newValue;.

Common mistakes: The declaration is missing the = sign. It should be let score = 0; so the variable starts with a value. let is used again for a variable that already exists, which is an error. To reassign it, write lives = lives - 1; with no let.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 562–580) and word search (Modules 522–580).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A game starts with let score = 0; Which line gives score a new value of 10?
let score = 10;score = 10;
Matches
let score = 0; let score = 10;
↓
let is written twice for the same name, which causes a SyntaxError because score is already declared.
Applying
Meanings
Term
score = score + 1;
Meaning
Reassigns an existing let variable. The right side is worked out first using the old value, then the new value replaces it. Don't write let again.
Practice
let score = 10;
Testing
Gaps
= 20;
Check Answer
Spots
1let score 0;
2score = 10;

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Hyena' badge — Savannah Debugger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A game starts with let score = 0; Which line gives score a new value of 10?
A. let score = 10;
B. score = 10; ✓
The variable already exists, so you just write score = 10; with no let. Writing let again would cause a SyntaxError.
2. What happens when you run this code? let lives = 3; let lives = 2;
A. Error: lives has already been declared ✓
B. lives is now 2
You can only declare a variable with let once. To change it later, use lives = 2; without let.
3. After this code runs, what is score? let score = 5; score = 8;
A. 8 ✓
B. 13
Using = replaces the old value. It does not add to it. The 5 is gone and score is now 8.
4. Which line adds 1 to score by using its old value?
A. score = score + 1; ✓
B. let score = score + 1;
The right side is worked out first using the old value. Then the result replaces the old value. You don't write let again.
5. let score = 4; score = score + 1; What is score now?
A. 1
B. 5 ✓
The computer works out score + 1 as 4 + 1 = 5 first, then stores 5 back in score.

Match the Pairs

score = 10; → Replaces the old value of the existing let variable score with 10, without writing let again.
score = score + 1; → Works out the old score plus 1 first, then stores that new value back in score.
To change a let variable that already exists, use its name and = only, with no let in front. → let lives = 3; lives = 2;
A new value can be built from the old value, because the right side is worked out before it is stored. → let score = 5; score = score + 2;
let score = 0; let score = 10; → let is written twice for the same name, which causes a SyntaxError because score is already declared.
let score = 4; score + 1; → score + 1 works out an answer but never stores it, so score is still 4. There is no = to reassign it.

Key Term

score = score + 1;
Reassigns an existing let variable. The right side is worked out first using the old value, then the new value replaces it. Don't write let again.

Fill in the Blanks

1. let score = 10; score = 20; console.log(score);
Hint: Type the name of the existing variable being given a new value (no let needed).
2. let score = 10; score = score + 1; console.log(score);
Hint: Type the arithmetic operator that adds one to the old value.
3. let lives = 3; lives = 2; console.log(lives);
Hint: Type the keyword used to create the variable the first time only.
4. let coins = 5; coins = coins * 2; console.log(coins);
Hint: Type the variable name that supplies the old value on the right side.
5. let points = 4; points = points + 3; console.log(points);
Hint: Type the symbol that stores the newly worked-out value back into the variable.

Spot the Error

Question 1
A let score 0;
B score = 10;
C score = score + 1;
D console.log(score);
Line A — The declaration is missing the = sign. It should be let score = 0; so the variable starts with a value.
Question 2
A let lives = 3;
B let lives = lives - 1;
C console.log(lives);
Line B — let is used again for a variable that already exists, which is an error. To reassign it, write lives = lives - 1; with no let.
Question 3
A let coins = 20;
B coins = coins + 5;
C console.log(coins);
D let coins = coins * 2;
E console.log(coins);
Line D — coins was already declared on line 1, so declaring it again with let causes an error. It should be coins = coins * 2; with no let.
Question 4
A let score = 0;
B score = score + 1;
C score = score + 1;
D score + 1;
E console.log(score);
Line D — This line works out score + 1 but never stores the answer, so score does not change. It should be score = score + 1; to replace the old value.
Question 5
A let points = 10;
B points + 5 = points;
C console.log(points);
Line B — The variable being updated must go on the left of =, and the new value is worked out on the right. It should be points = points + 5;

Student with a class code? Join your class →