The big picture
Lessons 1 to 4 build a function. Lessons 5 to 8 find what went wrong.
| Idea | Remember | Example |
|---|---|---|
| A name for steps | function names lines. Output does not change. | Same 8 lines print |
| What you hand it | A parameter starts empty. An argument fills it. | stops: dash, then 3 |
| The value it hands back | return sends a value out. Print sends nothing. | ticketFare(3) gives 8 |
| One call inside another | The inner call finishes first. | total(morning) before max |
| A print in the middle | It shows a box right then. | print(off) shows 6 |
| One line at a time | A dash means the box is not made yet. | 3 riders give 18 |
| Predict, then run | Predict from the job. Check the first difference. | Purse 8 differs |
| Halve the hunt | Check the middle. Drop the innocent half. | 4 checks, not 10 |
Two questions help in every bug hunt. What does a box hold? Where should I look next?
Name the part that repeats. Hand it a value. Predict before you run.