if i have a an array like below in JS
lineitems : [{
quantity : 1,
unitPrice : 10.00,
unitPriceLessTax: 8.33,
SKU: 'SKU123456',
productName: 'Blue T-Shirt'
},
{
quantity : 1,
unitPrice : 10.00,
unitPriceLessTax: 8.33,
SKU: 'SKU123456',
productName: 'Blue T-Shirt'
},
{
quantity : 1,
unitPrice : 48.00,
unitPriceLessTax: 40.00,
SKU: 'SKU78910',
productName: 'Red Shoes'
}]
how do i conver it to look like below
lineitems : [{
quantity : 2,
unitPrice : 10.00,
unitPriceLessTax: 8.33,
SKU: 'SKU123456',
productName: 'Blue T-Shirt'
},
{
quantity : 1,
unitPrice : 48.00,
unitPriceLessTax: 40.00,
SKU: 'SKU78910',
productName: 'Red Shoes'
}]
basically looking to merge duplicates based on SKU