Curly braces and indentation
Curly braces group the statements that belong to an if, loop or function. The code inside the braces is indented so you can see which block it belongs to.
Understanding Curly braces and indentation in ACARA Digital Technologies Years 7–8
What it does: The function body sits between { and }, with the line inside indented so you can see it belongs to greet. Both indented statements are inside the while block, so both are grouped by the same pair of braces. Every opening brace { needs a matching closing brace } on its own line. The wrong version is missing the closing brace. Putting } on its own line makes it easy to see where the block ends. JavaScript uses braces, not indentation, to find the end of a block. A missing } causes a syntax error. Curly braces mark which statements belong to the loop, and the indentation makes that body easy to see.
Common mistakes: The function block is closed with a round bracket. It must be closed with a curly brace } on its own line. The opening curly brace { is missing. It should go at the end of the first line: function add(a, b) {.
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 583–598) and word search (Modules 583–613).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
{ }Fill in the Blanks
Spot the Error
Student with a class code? Join your class →