Learn Advanced Array Methods by Building a Statistics Calculator - Step 51

Tell us what’s happening:

The instruction is:
Divide your .reduce() call by the length of the array (in your variance declaration). Then, return variance.
Error:
You should divide the result of the .reduce() call by the length of the array.

Problem: If I run this through the app it runs with no errors and provides the correct value. I am at a loss here. I assume it is something simple that I am missing. Any assistance in this regard would be much appreciated. Thank you.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const getVariance = (array) => {
  const mean = getMean(array);
  const variance = array.reduce((acc, el) => {
  const difference = el - mean;
  const squared = difference ** 2;
    return acc + squared / array.length;
}, 0);
    return variance
}


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn Advanced Array Methods by Building a Statistics Calculator - Step 51

you need to make the new operation outside the reduce method, not inside its callback. Even if the result is correct, it is not what you are asked to do.

Hi Ilenia, thank you. Still not getting it. Don’t worry, I’ll keep trying to figure it out. You’re a star.

Hi Ilenia, got it thank you. It was staring me in the face the whole time, I just didn’t see it. I think I got into an analysis paralysis tailspin for a while there. Thanks a million, you got the plane righted just before it hit the ground.