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

Tell us what’s happening:

i am stuck here, and cannot understand how to proceed , please someone tell me where my code is going wrong

Your code so far

/* file: script.js */
const getMean = (array) => array.reduce((acc, el) => acc + el, 0) / array.length;


// User Editable Region

const testArr1 = [1, 2, 3, 4, 5];
const testArr2 = [1, 2, 3, 4, 5, 6];
const isEven = testArr2.length % 2 === 0;
console.log(isEven);
const oddListMedian = testArr1[Math.floor(testArr1.length / 2)];
console.log(oddListMedian);
const evenListMedian = getMean(testArr2[(testArr2/2)], testArr2[(testArr2/2)-1]);
console.log(evenListMeadian);

// User Editable Region

const getMedian = (array) => {
  const sorted = array.sort((a, b) => a - b);
}

const calculate = () => {
  const value = document.querySelector("#numbers").value;
  const array = value.split(/,\s*/g);
  const numbers = array.map(el => Number(el)).filter(el => !isNaN(el));
  
  const mean = getMean(numbers);

  document.querySelector("#mean").textContent = mean;
}

Your browser information:

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

Challenge Information:

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

Hi there!
You have forget to use the length property of an array.

2 Likes

[quote=“edgyruchir, post:1, topic:700142”]
hello there , thanks for your response finally corrected this thank you for your help

1 Like