Published lesson · 30 minutes
Work with lists and repeat tasks
Objective: Store related values in an array and use a loop to produce a result for each item.
Understand the idea
Work with lists and repeat tasks works best when the learner can explain the reason behind each step, not just copy a result. An array keeps an ordered collection; a loop applies the same operation to each value without copying the same code many times.
A community garden records four plot names and wants to print each name with its available water slot. Treat the names and details as invented practice information; the example is for learning a method and does not describe a live service.
A dependable sequence is: Create a short array, use `for...of` to visit each item, and keep the output step inside the loop. Write down the important decision before you begin so another person can follow the reasoning.
Test with an empty list and a one-item list. Check that the loop neither invents output nor skips the first value. Compare the result with the objective, then change one thing at a time if the first attempt does not work.
Extend the example with one more plot and predict the output before running it. Explain one assumption that would need checking before anyone used a similar result outside the classroom.
Keep a short record of the choices you made and the evidence you used to check them. A useful practice result is understandable by another learner, stays within the stated scope and makes its limitations visible before anyone relies on it.
Worked examples
Work with lists and repeat tasks: practice example
Explore how work with lists and repeat tasks supports the lesson objective with a small synthetic example.
main.js
const plots = ["North bed", "South bed", "Herb corner"];
for (const plot of plots) console.log(`Water ${plot} on Thursday`);Practice tasks
Explore work with lists and repeat tasks
Use the worked example for “Work with lists and repeat tasks”. Change one small detail to suit a different synthetic community situation, then explain what you expected and how you checked whether the change still met the lesson objective.
Build a JavaScript practice example
Create a small practice result that demonstrates this objective: Store related values in an array and use a loop to produce a result for each item. Use only synthetic information, keep the first version focused, and write down one limitation that a later version should address.
Review and explain the result
Review your “Work with lists and repeat tasks” result as if another learner will use it without your explanation. Identify one strength, one exact point that may be unclear, and a revision that would make the result easier to understand or use.
Work with lists and repeat tasks becomes easier when you create a short array, check the result and explain the choice to another learner.
Course overview