← ACARA Digital Technologies Years 9–10

Reading a JavaScript error message

The console text that names the error type, such as SyntaxError or TypeError, and the line number where it happened, so you know what went wrong and where to look.

Understanding Reading a JavaScript error message in ACARA Digital Technologies Years 9–10

What it does: This message shows broken grammar in the code, such as a missing closing bracket, and it appears before the program runs. The script.js:7 part gives the file and line number, so the student knows to check line 7 first. The first words of the message name the error type. A ReferenceError means you used a name that JavaScript has not seen declared. A ReferenceError names the missing variable, which tells the student to check the spelling or the declaration. A TypeError of the 'x is not a function' kind means the name before the brackets is not a method or function, so check its name and where it is defined.

Common mistakes: The console would report a SyntaxError (Unexpected token ';') on line 1. The variable has no value after the = sign. It should be const score = 10;. The console would report ReferenceError: nmae is not defined, pointing at line 2. The variable name is misspelled. It should be console.log(name);.

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 710–727) and word search (Modules 710–742).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Your code runs and the console shows: ReferenceError: score is not defined. What does this tell you?
The error type is ReferenceError and the variable score was used without being declaredThe error type is SyntaxError and the computer cannot read the file
Matches
console.log(score;
↓
The closing bracket is missing, so the console shows a SyntaxError. Add ) before the semicolon.
Applying
Meanings
Term
error message
Meaning
The console text that names the error type, such as SyntaxError or TypeError, and the line number where it happened, so you know what went wrong and where to look.
Practice
try {
Testing
Gaps
catch (e) { console.log(e.); }
Check Answer
Spots
1const score = ;
2console.log(score);

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

The 'Snowy Owl' badge — List Slicer, 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. Your code runs and the console shows: ReferenceError: score is not defined. What does this tell you?
A. The error type is ReferenceError and the variable score was used without being declared ✓
B. The error type is SyntaxError and the computer cannot read the file
The first words of the message name the error type. A ReferenceError means you used a name that JavaScript has not seen declared.
2. The console shows: SyntaxError: Unexpected token ')' at script.js:7. Where should you start looking?
A. Line 1 of script.js, because errors always start at the top
B. Line 7 of script.js, checking the brackets and punctuation ✓
The line number in the console tells you where JavaScript noticed the problem. Start there, and check the line just before it too.
3. Which line of code would cause this error: TypeError: total is not a function?
A. let total = 5; console.log(totl);
B. let total = 5; total(); ✓
A TypeError: x is not a function means you tried to call something with () that is not a function. Calling the number total() does that. The second line would give a ReferenceError instead.
4. Which error type would you see for this code: console.log(playerName); when playerName was never declared?
A. ReferenceError ✓
B. SyntaxError
JavaScript can read the code fine, but it cannot find the name playerName. That is a ReferenceError. A SyntaxError means the code is written in a way JavaScript cannot read.
5. Which error type would you see for this code: let x = (5 + 2;
A. SyntaxError ✓
B. ReferenceError
The closing bracket is missing, so JavaScript cannot understand the code. Broken grammar like this is a SyntaxError.

Match the Pairs

ReferenceError: score is not defined → The code uses a variable name that was never declared, so JavaScript cannot find it
TypeError: player.jump is not a function → The code tried to call something as a function, but it is not a function (it may be missing or misspelled)
A SyntaxError means the code is written wrongly, such as a missing bracket, so JavaScript cannot run it → SyntaxError: missing ) after argument list
The line number in the console tells you where to start looking for the problem → script.js:7 Uncaught ReferenceError: total is not defined
console.log(score; → The closing bracket is missing, so the console shows a SyntaxError. Add ) before the semicolon.
let name = 'Ava'; console.log(nme); → nme is misspelled, so the console shows a ReferenceError: nme is not defined. Change it to name.

Key Term

error message
The console text that names the error type, such as SyntaxError or TypeError, and the line number where it happened, so you know what went wrong and where to look.

Fill in the Blanks

1. try { console.log(missing); } catch (e) { console.log(e.name); }
Hint: Type the error property that holds the error type, such as ReferenceError.
2. try { null.length; } catch (e) { console.log(e.message); }
Hint: Type the error property that holds the description of what went wrong.
3. try { let n = 5; n(); } catch (e) { console.log(e.name === "TypeError"); }
Hint: Type the error type you get when you call something that is not a function.
4. try { throw new SyntaxError("Bad"); } catch (e) { console.log(e.name); }
Hint: Type the error type used when the code is written with broken grammar, like a missing bracket.
5. try { undefinedFn(); } catch (e) { console.log(e.stack); }
Hint: Type the error property that lists where the error happened, including the line number.

Spot the Error

Question 1
A const score = ;
B console.log(score);
C console.log(score + 5);
Line A — The console would report a SyntaxError (Unexpected token ';') on line 1. The variable has no value after the = sign. It should be const score = 10;
Question 2
A let name = 'Mia';
B console.log(nmae);
C console.log('Done');
Line B — The console would report ReferenceError: nmae is not defined, pointing at line 2. The variable name is misspelled. It should be console.log(name);
Question 3
A let count = 3;
B let items = [1, 2];
C items.push(count);
D count(items);
Line D — The console would report TypeError: count is not a function on line 4. count holds a number, and the round brackets try to call it. It should be console.log(items);
Question 4
A const pet = 'dog';
B console.log(pet);
C let big = pet.toUppercase();
Line C — The console would report TypeError: pet.toUppercase is not a function on line 3. JavaScript is case sensitive, so the method name must be toUpperCase.
Question 5
A let age = 15;
B if (age >= 14 {
C console.log('Teen');
D }
Line B — The console would report a SyntaxError on line 2 because the closing bracket is missing. It should be if (age >= 14) {

Student with a class code? Join your class →