Skip to content
Your progress

Checking your sign-in…

Who's learning?

Each profile keeps its own read lessons, badges, streak, and practice scores on this device.

Lesson 0 of 11

3 min

Text size

Two bus stops need the same three lines.

One name, called twice, prints the same 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. function gives a group of lines one name.
  • What you hand it. A parameter starts empty. An argument fills it.
  • The value it hands back. return is not the same as print.
  • 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.