In this course, you’ll learn to write functions that loop over a list and answer a question about it. You’ll finish by building an expedition supply checker for a four-day hike.
What You’ll Build
The group’s gear fills eight crates, each with a name and a weight. Your supply checker answers four questions about them:
- How many crate names are too long for a printed label? It counts four.
- Which names are they? It selects them into a new list.
- How much does the whole load weigh? 23 kilograms.
- Which weight is the first one over 3 kilograms? It finds 9 kilograms.
What You’ll Be Able to Do
- Write functions that take a list and choose a loop to count, total, select, find or compare its items.
- Decide what each function returns for an empty list.
You’ll start small, by building a list, visiting each of its items and using positions. Then you’ll learn the loop patterns one by one.
How You’ll Work
- You’ll run scripts in the VS Code terminal.
- You’ll practice in on-site exercises, whose tests show you what to fix.
- The supply checker comes last, with a mentor review where you explain your code.
You should be comfortable running scripts with node and writing functions with loops, if blocks and return values.
This course comes with sample code and a cheat sheet. The sample code has the files you’ll create in the lessons, plus a starter and a solution for each exercise. Keep the JavaScript cheat sheet open as a quick reference while you work:
Up next is Read and Build a List.