Level 2 · Web Development Basics · Course 2.3 Introduction to JavaScript
Module 18: Decisions and Functions
Goal: make programs that choose what to do with conditions, repeat work with loops, and organise code into reusable functions.
You'll need: VS Code, the browser console and your js/main.js from Module 17.
Lessons
- 1Conditions15–25 minutes✓
- 2Loops15–25 minutes✓
- 3Functions15–25 minutes✓
- 4Parameters and return values15–25 minutes✓
- 5Scope and reading code15–25 minutes✓
🛠️Module practice: course helper functions
In js/main.js, write and test (in the console):
findLevel(modulesDone): returns the level as text.calculateFee(perMonth, months, hasDiscount): returns the total, 10% less whenhasDiscountistrue.listCourses(courses): takes an array of names and returns a single numbered string.- Test each with at least three inputs, including edge cases (0 modules, 0 months, an empty array).
Commit your work.
✅Module check
Explain in a few sentences, in your own words:
What are conditions, loops and functions, and how would you read an unfamiliar function?
Show a good answer
A good answer mentions: conditions (if/else) choose which code runs; loops repeat code, for example for
every item in an array; functions are named, reusable blocks that take parameters and return results. To read
one: its name and parameters (input), its return statements (output), the conditions inside, anything it
changes outside, then try it with simple values.
📝Module quiz
10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·
