if I have two (large) arrays that specify a key and a numeric value
var a = [
{ gtin: 'a1', quantity: 1 },
{ gtin: 'a3', quantity: 1 },
];
var b = [
{ gtin: 'a1', quantity: 1 },
{ gtin: 'a4', quantity: 1 },
];
what is the easiest way to get a single array that sums the quantities? (Lodash ok, fewest iterations over array preferred)
ie
[
{ gtin: 'a1', quantity: 2 },
{ gtin: 'a3', quantity: 1 },
{ gtin: 'a4', quantity: 1 },
];