var dateEntries = [{
name: 'foo',
startDate: '2017-11-10 09:00',
endDate: '2017-11-23 11:00'
}, {
name: 'bar',
startDate: '2017-11-10 09:01',
endDate: '2017-11-23 11:00'
}, {
name: 'baz',
startDate: '2017-11-10 09:00',
endDate: '2017-11-24 10:00'
}, {
name: 'biz',
startDate: '2017-11-10 09:01',
endDate: '2017-11-25 09:00'
}, {
name: 'quick',
startDate: '2017-11-10 09:00',
endDate: '2017-11-23 11:00'
}, {
name: 'brown',
startDate: '2017-12-10 09:00',
endDate: '2017-11-23 11:00'
}, {
name: 'fox',
startDate: '2017-12-10 10:00',
endDate: '2017-11-23 11:00'
}];
var startDateOccurrences = dateEntries.reduce(function (tempCollector, date) {
var
startDateStr = date.startDate,
count = tempCollector.directory[startDateStr];
if (!count) {
count = tempCollector.directory[startDateStr] = {
startDate : date.startDate,
occurrence : 0
};
tempCollector.list.push(count);
}
count.occurrence += 1;
return tempCollector;
}, {
directory: {},
list: []
}).list;
console.log('startDateOccurrences : ', startDateOccurrences);
.as-console-wrapper { max-height: 100%!important; top: 0; }