在合併重複的,如果我有一個數組像下面的JSJavaScript數組
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'
}]
我如何CONVER它看起來像下面
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'
}]
基本上尋求合併基於SKU
重複
請你要比較的形成你的更好的可視性 – Saar
代碼? –