Given an array of objects representing a series of transactions i.e.
[{ person: 'a', sweets: 5 }, { person: 'b', sweets: 8 }, { person: 'a', sweets: 6 }]
How can I efficiently consolidate these records, to a total tally for each person i.e. :
[{ person: 'a', sweets: '11'}, { person: 'b', sweets: 8 }]
Is there some inbuilt function I donlt know about, or would I have to prototype one?