I have an array like this
[ { item_guid: "57e7a1cd6a3f3669dc03db58" quantity:3 }, { item_guid: "57e77b06e0566d496b51fed5" quantity:3 }, { item_guid: "57e7a1cd6a3f3669dc03db58" quantity:3 }, { item_guid: "57e77b06e0566d496b51fed5" quantity:3 } ]
What I want from this is to merge a similar item_guid into one object and quantity, thus summing up
[ { item_guid: "57e7a1cd6a3f3669dc03db58" quantity:6 }, { item_guid: "57e77b06e0566d496b51fed5" quantity:6 } ]
I know this can be achieved in some kind of cycle, instead I am looking for solutions that use lodash or EcmaScript2015 code to make our life easier.
source share