What you hand it, and what each end is called
Show on a big screenA fare needs two answers. How many stops? Who is riding?
fare(stops, rider) waits for two values.fare(stops, rider)waits for two values.fare(3, "adult")fills both slots.fare(2)fills only one.- 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".
| Word | Written where | What it is |
|---|---|---|
| Parameter | In the definition | A name, empty until a call |
| Argument | In the call | A 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.