Question
Why is my returned average value incorrect?
Answer
A common mistake is writing out a step like numerator / denominator
on a line by its own and then trying to return total. This is close, but it won’t store that result anywhere unless you tell it to!
Better yet, we can write that all on the same line as the return
and save ourselves from having to create another variable, like this: return numerator / denominator
.
Remember that performing math like that on a line of its own simply does the math and moves on without storing it anywhere unless you assign it to some variable.