This is my code
var array = [{
OrderId: "L01",
Location: "London"
Qty: "6.00",
Status: "Product A
},
{
OrderId: "L01",
Location: "London"
Qty: "2.00"
Status: "Product B"
},
{
OrderId: "L01",
Location: "London"
Qty: "3.00"
Status: "Product C"
},
{
OrderId: "P01",
Location: "Paris"
Qty: "7.00"
Status: "Product A"
},
{
OrderId: "P01",
Location: "Paris"
Qty: "4.00"
Status: "Product B"
},
{
OrderId: "P01",
Location: "Paris"
Qty: "9.00"
Status: "Product C"
}
];
I want to convert this array to
var arrayModified = [{
OrderId: "L01",
Location: "London"
QtyA: "6.00",
QtyB: "2.00,
QtyC: "3.00
},
{
OrderId: "P01",
Location: "London"
Qty: A "7.00",
QtyB: "4.00",
QtyC: "9.00"
}
];
Basically i want to check variable called status and based on that I have to create new fields QtyA, QtyB, QtyC. OrderId and Plant are common and unique fields.
How can I achieve this functionality in plain JS without Jquery and Lodash.