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

Tell us what’s happening:

The variance formula might be wrong? I think it should be divided by (n-1) instead of n.
image

Your code so far

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

Your browser information:

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

Challenge Information:

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

1 Like

the two formulas are both correct, they are used for different things

see this explanation if you want to go deeper

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.