I\'m trying to count duplicates in an array of dates and add them to a new array.
But i\'m only getting the duplicates and the amount of times they exist in the array. <
For that, you can use .reduce:
.reduce
var arr = ['a','a', 'b', 'c', 'c']; var result = arr.reduce(function(p,c){ if(p[c] === undefined) p[c] = 0; p[c]++; return p; },{}); console.log(result);