I have an API response (committers to a git project) where members are repeated due to them having the same name but different email address.
Sample response:
[
{"id": "122334", "name": "bob", "commits":10, "email": "1@abc.com"},
{"id": "223411","name": "frank", "commits":4, "email": "frank@whatever.com"},
{"id": "223411","name": "bob", "commits":19, "email": "bob@aol.com"},
]
So here I want to produce a result like:
[
{"name": "bob", "commits":29},
{"name": "frank", "commits":4},
]
It feels like there is need for both a reduce and a loop.... but perhaps someone can suggest a simpler way as this feels like a common everyday kind of thing!
I looked a little in underscore.js and it's groupBy function but it feels like overkill for a single usage and I couldn't get that working either :)