let arr = [1,1,1,2,2,3]
var count = new Map();
for(num in arr){
if (count.size !== 0 && count.has(arr[num])){
count = count.set(arr[num],1+ count.get(arr[num]))
}
else{
count = count.set(arr[num],1);}
/* Output
Map(3) { 1 => 3, 2 => 2, 3 => 1 }
*/