What the message says, and what it does not
Show on a big screenFour lines in the ticket program are broken. Not one of them runs.
Loading lab…
- The run stops on line 3.
- This chip names the line it stopped on.
- This line says what went wrong.
- This line suggests a way to fix it.
The rule
An error is the machine telling you what it could not do. It is not a score.
An error message names the line the run stopped on. It says what could not be done there. The cause can be on that line or above it. Fix one thing, then run it again.
These four sentences are this editor's own. Other tools phrase them differently, or run some of these lines anyway.
| The line | What came back |
|---|---|
print(total); | I do not know what total is. Did you make it with let first? |
print(min(fare, riders, 2)); | min needs 2 values, but you gave 3. |
print("Fare " - fare); | You cannot do a text - a number. Check the values on this line. |
print(riders / 0); | You cannot divide by zero. Check the number on the right. |
The first message names line 3, where total is used. The missing line is above it, where the box should be made. The machine can only say where it stopped.
In the other three, the cause is on the line itself. min picks the smaller of its values. Here min needs exactly 2 values.
Change four lines at once and you cannot tell which change mattered.
Try the lab to finish this lesson.