Skip to content
Exit presentation

Computational Thinking III: Functions & Debugging

Start here

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.

Jump to lesson

This track

  1. 0 Start here
  2. 1 A name for a group of steps
  3. 2 What you hand it, and what each end is called
  4. 3 The value it hands back
  5. 4 One call inside another
  6. 5 A print in the middle
  7. 6 One line at a time
  8. 7 Predict, then run
  9. 8 Halve the hunt
  10. 9 The big picture
  11. 10 Track quiz

Other tracks