I need the count of my objects in the array based on their type. I don't know what I'm missing here, but this is what I do:
myCounts = (myArray || []).reduce(function _countMembersByType(counts, member) {
return counts[member.type === productType.GROUP ? 'groupCount' : 'individualCount']++;
}, {groupCount: 0 , individualCount: 0});
When myArray has members, myCounts will be null. Otherwise, it will be an object as myCounts: {"groupCount":0,"individualCount":0} as I would expect.
I'm new to JS and would appreciate any help!