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 2 of 11

What you hand it, and what each end is called

Show on a big screen

6 min

Text size

A fare needs two answers. How many stops? Who is riding?

fare(stops, rider) waits for two values.
Step 1 of 4
  1. fare(stops, rider) waits for two values.
  2. fare(3, "adult") fills both slots.
  3. fare(2) fills only one.
  4. The run stops. It needs 2 values and got 1.

Read each card below. Tap Parameter or Argument.

Loading lab…

The rule

The call gives both answers. In fare(3, "adult"), there are 3 stops and an adult is riding.

In function fare(stops, rider), stops and rider start empty. A call fills them.

The name written in the brackets of the definition is the parameter. The value written in the brackets at the call is the argument.

A parameter is a name in the definition. An argument is a value in the call.

fare(3, "adult"); hands over 3 and "adult". The values fill the parameters in order. So stops is 3 and rider is "adult".

Where each word is written
WordWritten whereWhat it is
ParameterIn the definitionA name, empty until a call
ArgumentIn the callA value, handed over

Call fare(2) with one value, not two. Then rider has no value. In this language, the run stops with a message:

` fare needs 2 values, but you gave 1. `

Try the lab to finish this lesson.