Currently, I got an array like that:
var uniqueCount = Array();
After a few steps, my array looks like that:
uniqueCount =
It is simple in javascript using array reduce method:
const arr = ['a','d','r','a','a','f','d']; const result = arr.reduce((json,val)=>({...json, [val]:(json[val] | 0) + 1}),{}); console.log(result) //{ a:3,d:2,r:1,f:1 }