What happens the moment a return runs?
- The function restarts
- The caller waits forever
- The function ends on the spot
What is a return value for?
- Making code run faster
- Letting later code use a computed result
- Printing text on screen
A function that prints shows output, while one that returns delivers a value.
Circle one: True False
In calcLineSlope, the return sits above the slope maths. What runs?
- Everything above the return, then it exits
- The whole function as normal
- Only the line below the return
calcScore returns correct out of 30 times 100. What does calcScore(27) hand back?
Answer: ______________
A total is made inside a function. What happens if later code outside tries to print it?
- It prints the total as normal
- It fails, since the name vanished with the call
- It prints zero
You need one score in three later sums. What is the right design?
- Return the score and store it once for reuse
- Print the score and retype it each time
- Make the score global so anyone grabs it
Where is the bug in calcLineSlope, and what is the fix?
- The maths is wrong, so delete it
- The parameters are wrong, so swap them
- Return runs too early, so move it to the last line