const data = [
{
product_id: 1245,
product_name: "XYZ",
price: "10.00",
batch_number: 1,
},
{
product_id: 12456,
product_name: "RST",
price: "10.00",
batch_number: 1,
},
{
product_id: 111,
product_name: "LMN",
price: "10.00",
batch_number: 2,
},
{
product_id: 222,
product_name: "PQR",
price: "10.00",
batch_number: 2,
},
{
product_id: 456,
product_name: "KKK",
price: "10.00",
batch_number: null,
},
];
i want to format this object into an this type with add same batch number product in to product id and product name and price as combained. Is there any way to cahnge this. How do cahnge this to that expectedoutput Expected output
const output = [
{
product_id: "1245, 12345",
product_name: "XYZ, RST",
price: "20.00",
batch_number: 1,
},
{
product_id: "111, 222",
product_name: "LMN, PQR",
price: "20.00",
batch_number: 2,
},
{
product_id: 456,
product_name: "KKK",
price: "10.00",
batch_number: null,
},
];