let arr = [1,2,3,4,5,3,2,1,1,1,1];
let map = {};
for(let i = 0; i < arr.length; i++){
const key = arr[i];
if(map[key]){
map[key]++
} else {
map[key] = 1;
}
}
let max = {count: -1, num: -1};
for(key in map) {
if(max.count < map[key]){
max.count = map[key],
max.num = key;
}
}
// Object.keys(map).map((item) => {
// max = Math.max(map[item], max);
// })
console.log(map, '----', max);