# Learn Advanced Array Methods by Building a Statistics Calculator - Step 38

### Tell us what’s happening:

I’m having trouble with this step. I’ve read the other forum posts and i think i am close.

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

const getMedian = (array) => {
const sorted = array.sort((a, b) => a - b);
const median =
array.length % 2 === 0
? getMean([sorted[array.length / 2], sorted[array.length / 2 - 1]])
: sorted[Math.floor(array.length / 2)];
return median;
}

// User Editable Region

const getMode = (array) => {
const counts = {};
array.forEach((el) => {
counts[el] = (counts[el] || 0) + 1;
})
if (new Set(Object.values(counts)).size === 1) {
return null;
}
const highest = Object.keys(counts).sort((a,b) => {counts[b] - counts[a]})[0];
}

// User Editable Region

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);
const median = getMedian(numbers);

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

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 38

can you explain what issue you are having?

``````const highest = Object.keys(counts).sort((a,b) => {counts[b] - counts[a]})[0];
``````
``````Your getMode function should use the sort method to sort the Object.keys() array and return the value of counts[b] minus the value of counts[a].
Your highest variable should have the value of the first entry in the sorted Object.keys(counts) array.
``````

your callback is not returning anything, you may want to fix that

thank you for your help @ilenia