Lesson 5 of 10

Magic machines

A function is a machine with one job.

Machines can take:
  • numbers
  • words

Scene 1 of 5

This machine is called double. 3 goes in, 6 comes out!

A machine called double. In: 3. Out: 6.
Scene 1 of 5

Tip

Build a machine once, then use it again and again.

Library

All about functions

What is a function?

A function is a machine with one job. Something goes in. Something comes out.

Building a machine

You write function, then a name. Inside, you tell the machine its job.

Using a machine

Write the name, then put something in round brackets. That is called a call.

What comes out

return sends the answer out of the machine.

Machines
double
In and out
3 in, 6 out
Words too
hi in, HI! out

Words to know

  • function = a machine with one job
  • call = use the machine
  • return = send the answer out