In Javascript, I\'m trying to take an initial array of number values and count the elements inside it. Ideally, the result would be two new arrays, the first specifying each
function countOcurrences(arr){ return arr.reduce((aggregator, value, index, array) => { if(!aggregator[value]){ return aggregator = {...aggregator, [value]: 1}; }else{ return aggregator = {...aggregator, [value]:++aggregator[value]}; } }, {}) }