Lesson 16: Control Flow — if, for, and Functions
The final lesson ties it all together. Until now each command ran once. Now we learn to decide (`if`), repeat an action (`for`), and pack code under a name (a function). These are the building blocks of every real script.
if is 'if it rains, take an umbrella'. for is 'for each kid in class, hand out a page'. A function is a saved recipe you can call by name.
- if (condition)
- Runs code only if a condition is true
- for (loop)
- Repeats an action for each item in a list
- Function
- A named block of code you can call again and again