xxxxxxxxxx
function mode(numbers) {
const numCount = {};
for (const num of numbers) {
if (numCount[num] === undefined) {
numCount[num] = 0;
}
numCount[num] += 1;
}
let max = null;
let maxNum = null;
for (const num in numCount) {
if (numCount[num] > max) {
max = numCount[num];
maxNum = num;
}
}
return maxNum;
}