[Solved] How do I get the elements in an array with the highest occurrency? [closed]
var arr = [0, 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 7, 7, 7, 8, 9, 10, 10, 10] var uniq = arr.reduce((all, next) => { var exist = all.find(v => v.key === next) if (exist) { exist.count += 1 exist.val.push(next) } else { all.push({ key: next, count: 1, val: [next] … Read more