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. <
lodash's countBy function will do the trick:
lodash
countBy
_.countBy(['a', 'a', 'b', 'c', 'c']) will evaluate to: {a: 2, b: 1, c: 2}
_.countBy(['a', 'a', 'b', 'c', 'c'])
{a: 2, b: 1, c: 2}
It does involve adding lodash as a dependency though.