Currently, I got an array like that:
var uniqueCount = Array();
After a few steps, my array looks like that:
uniqueCount =
Nobody responding seems to be using the Map()
built-in for this, which tends to be my go-to combined with Array.prototype.reduce()
:
const data = ['a','b','c','d','d','e','a','b','c','f','g','h','h','h','e','a'];
const result = data.reduce((a, c) => a.set(c, (a.get(c) || 0) + 1), new Map());
console.log(...result);
N.b., you'll have to polyfill Map() if wanting to use it in older browsers.