JavaScript mais frequente em uma lista
function findMostFrequent(arr) {
var repsCount = {};
for (i = 0; i < arr.length; i++) {
if (!repsCount[arr[i]]) {
repsCount[arr[i]] = 1;
} else {
repsCount[arr[i]] = repsCount[arr[i]] + 1;
}
}
var occursMore = [];
for (var key in repsCount) {
if (repsCount[key] > occursMore) {
occursMore.push(key);
}
}
return occursMore;
}
Fierce Ferret