Modifying an existing JavaScript program
Read the code and predict what it does, change one small part (a value, condition or message), run it, then compare the result with your prediction.
Understanding Modifying an existing JavaScript program in ACARA Digital Technologies Years 7–8
What it does: An extra else if adds a new branch to the existing program without rewriting the parts that already work. Editing one part of a loop, such as the 3 in i < 3 changed to 5, lets you predict how many lines print, run it and compare. Read and predict first. Then you can tell whether your change did what you expected. Changing one thing at a time means that if something breaks, you know which change caused it. Running the program and comparing the result with your prediction shows whether you understood the code. A copy lets you go back to the working version if your changes cause bugs.
Common mistakes: The change to the value uses the wrong operator. '--' is not valid between two values, so the program will not run. It should be 'lives = lives - 1;'. The message uses the number 1 instead of the loop counter i, so every lap prints 'Lap 1'. It should be console.log("Lap " + i);.
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 624–634) 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.
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
predict, change, runFill in the Blanks
Spot the Error
Student with a class code? Join your class →