Functions & Program Design
Turn growing scripts into small, reusable functions with clear inputs, predictable returns, and well-managed state.
Variables, conditionals, loops, and basic string/number operations.
Break a program into small functions with clear inputs and returns, use closures for private state, and compose higher-order functions without hiding control flow.
Read in order, or jump to what you need.
Every lesson builds on the one before it. Open any lesson to read the explanation, run the examples, and try the practice challenges.
- 03.01Defining & Calling Functions4 min
Write reusable blocks of code, pass values into them, and use what they return.
- 03.02Parameters, Defaults & Return Values4 min
Design predictable function contracts with defaults, rest parameters, guard clauses, and structured results.
- 03.03Scope, Closures & Private State4 min
Control where values live, keep state private with closures, and decide when that state should be released.
- 03.04Arrow Functions & Higher-Order Functions4 min
Write compact arrows, pass functions as values, and compose readable data pipelines.
- 03.05Project: Number Guessing GameProject4 min
Build a deterministic game engine with private state and an interactive console loop.
Ready to move on?
Implement a deterministic number-guessing game engine and play a full round through its public functions.
Open the module self-check