← ACARA Digital Technologies Years 7–8

Syntax errors: missing quotes, brackets and braces

An error shown when code breaks JavaScript's rules, like a missing quote, bracket or brace. JavaScript can't read the code, so the program won't run until you fix it.

Understanding Syntax errors: missing quotes, brackets and braces in ACARA Digital Technologies Years 7–8

What it does: This code has its opening brace and closing brace paired up, so JavaScript can read the whole if block. The string starts and ends with a double quote, so it is a complete string and there is no SyntaxError. Every opening { needs a matching closing }. Without it you get a SyntaxError such as 'Unexpected end of input'. A SyntaxError is about broken rules, like a missing quote, bracket or brace. A program that runs but gives wrong answers has a logic error. An unexpected token means JavaScript found a symbol where it didn't expect one. Check the reported line and the lines just above it.

Common mistakes: The string "Hi " is missing its closing quote, so JavaScript throws a SyntaxError (unclosed string). It should be console.log("Hi " + name);. The block that opened with { must be closed with a closing brace }, not a bracket ). This causes a SyntaxError. Line 4 should be }.

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 611–623) and word search (Modules 611–634).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which line causes a SyntaxError?
console.log("Hello");console.log("Hello);
Matches
if (score > 50 { console.log("Pass"); }
↓
The closing bracket ) is missing after the condition, so JavaScript gives a SyntaxError. It should be if (score > 50) {
Applying
Meanings
Term
SyntaxError
Meaning
An error shown when code breaks JavaScript's rules, like a missing quote, bracket or brace. JavaScript can't read the code, so the program won't run until you fix it.
Practice
function greet(name) {
Testing
Gaps
pet = "Rex";
Check Answer
Spots
1let name = "Ava";
2console.log("Hi + name);

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

The 'Octopus' badge — Multi-Tasker, 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. Which line causes a SyntaxError?
A. console.log("Hello); ✓
B. console.log("Hello");
The string starts with a quote but never closes it. This is an unclosed string, so JavaScript can't read the code.
2. True or false: a program with a SyntaxError will run until it reaches the broken line, then stop.
A. True: the lines before the error still run
B. False: JavaScript reads the code first, so nothing runs until the syntax is fixed ✓
A syntax error stops the whole program from starting because JavaScript can't read the code.
3. Which if statement has a missing closing brace?
A. if (age > 12) { console.log("Teen"); ✓
B. if (age > 12) { console.log("Teen"); }
Every opening { needs a matching closing }. Without it you get a SyntaxError such as 'Unexpected end of input'.
4. What does a SyntaxError message tell you?
A. Your code ran but gave the wrong answer
B. Your code broke JavaScript's rules and can't be read ✓
A SyntaxError is about broken rules, like a missing quote, bracket or brace. A program that runs but gives wrong answers has a logic error.
5. Which line has a missing closing bracket?
A. console.log("Score: " + score; ✓
B. console.log("Score: " + score);
The ( after log needs a matching ) before the semicolon. Missing it causes a SyntaxError.

Match the Pairs

console.log("Hello); → A string that is never closed, because the closing quote is missing. This causes a SyntaxError.
SyntaxError: Unexpected token '}' → JavaScript found a symbol it did not expect, often because brackets or braces do not pair up.
Every opening curly brace { needs a matching closing brace } to avoid a SyntaxError → if (age >= 13) { console.log("Teen"); }
Every opening quote needs a matching closing quote so the string is complete → let name = "Ava";
if (score > 50 { console.log("Pass"); } → The closing bracket ) is missing after the condition, so JavaScript gives a SyntaxError. It should be if (score > 50) {
for (let i = 0; i < 3; i++) { console.log(i); → The closing brace } is missing at the end of the loop, so JavaScript gives a SyntaxError. Add } on a new line after console.log(i);

Key Term

SyntaxError
An error shown when code breaks JavaScript's rules, like a missing quote, bracket or brace. JavaScript can't read the code, so the program won't run until you fix it.

Fill in the Blanks

1. // Both quotes are here, so this runs let pet = "Rex";
Hint: Type the keyword that declares a variable.
2. function greet() { console.log("Hi"); }
Hint: Type the symbol that closes the function body.
3. // A missing quote causes a SyntaxError console.log("Hi");
Hint: Type the name of the error JavaScript shows when code breaks its rules.
4. // Unexpected token = stray symbol console.log("Hi");
Hint: Type the word that follows 'Unexpected' in this common error message, meaning a piece of code JavaScript can't read.
5. if (score > 50) { console.log("Pass"); }
Hint: Type the keyword that starts a condition check before the curly braces.

Spot the Error

Question 1
A let name = "Ava";
B console.log("Hi + name);
C console.log(name);
Line B — The string "Hi " is missing its closing quote, so JavaScript throws a SyntaxError (unclosed string). It should be console.log("Hi " + name);
Question 2
A let score = 10;
B if (score > 5) {
C console.log("Pass");
D )
E console.log("Done");
Line D — The block that opened with { must be closed with a closing brace }, not a bracket ). This causes a SyntaxError. Line 4 should be }.
Question 3
A let a = 2;
B let b = 3;
C console.log(a + b;
Line C — The closing bracket ) is missing, so console.log( is never closed. JavaScript gives a SyntaxError. It should be console.log(a + b);
Question 4
A let name = "Mia";
B let age = 13;
C let city = Perth";
D console.log(city);
Line C — The opening quote before Perth is missing, so the string is not written correctly and gives a SyntaxError. It should be let city = "Perth";
Question 5
A let temp = 30;
B let hot = temp > 25;
C if (hot {
D console.log("Hot");
E }
Line C — The condition is missing its closing bracket ) before the {. This is a SyntaxError. It should be if (hot) {

Student with a class code? Join your class →