We use cookies to improve your experience. By using our site, you agree to our Cookies Policy.
const getMean = (array) => array.reduce((acc, el) => acc + el, 0) / array.length;
const getMedian = (array) => { const sorted = array.toSorted((a, b) => a - b); const median = sorted.length % 2 === 0 ? getMean([sorted[sorted.length / 2], sorted[sorted.length / 2 - 1]]) : sorted[Math.floor(sorted.length / 2)]; return median; }
2/12/2025, 10:27:52 PM