Building a modular program with functions, arrays and classes
A program built from small parts: a class for the data, an array of its objects, and helper functions that each do one job (like totals or searches), all run by a main function.
Understanding Building a modular program with functions, arrays and classes in ACARA Digital Technologies Years 9–10
What it does: main() does not do the work itself. It calls helpers like totalPoints() and uses the results. The class is the data part of the program. Its constructor sets the properties for every new object. The class is the blueprint for the data. Helper functions use the objects, they do not define the data. Each function should do one job. Then you can test it by itself and reuse it. The helper needs the array to search through, so the array is passed in as an argument. Small functions with one job can be checked with console.assert before you put the parts together.
Common mistakes: Inside a constructor the data must be stored on the new object with this. Without it, name = name only reassigns the parameter and the object gets no name. It should be this.name = name;. for...in gives the index positions (as text), not the objects, so s.mark would be undefined and the total would be NaN. To visit each object use for...of: for (const s of list) {.
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 743–781) and word search (Modules 743–809).
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
modular programFill in the Blanks
Spot the Error
Student with a class code? Join your class →