Lesson 0 of 11
Start here
Show on a big screenTwo bus stops need the same three lines.
This track is Functions and Debugging. It has two halves. First you build a function. Then you find out why a program is wrong.
Debugging means finding and fixing bugs, the mistakes in a program. To hand a function a value means to give it one. To hand back means to give back.
What you will learn
- A name for steps.
functiongives a group of lines one name. - What you hand it. A parameter starts empty. An argument fills it.
- The value it hands back.
returnis not the same asprint. - One call inside another. The inner call finishes first.
- A print in the middle. It shows what a box holds there.
- One line at a time. A table shows every box.
- Predict, then run. Work out the answer before the program does.
- Halve the hunt. Check the middle of the lines, then check again.
Need a quick recap?
- Typing it out — you type each line yourself.
- `let` and `const` — a box that can change, and one that cannot.
- Finding a bug — a bug is a mistake in a program. Read a line, then check what it did.