Trying to fix my reduce function

Hi,

In the solution, we have

Notice that the division is outside of the reduce function. The average is (sum / length), but you were incrementally summing and dividing, which results in a very different calculation.

Edit, you can repair your accumulator function by only dividing the current value instead of the sum of the current value and the accumulator.

6 Likes