if two objects in the data array contains same id the first will be picked and the other(s) discarded. multiple assets of same id should be in one object.
const myMap = cardDetails.map((card) => {
return {
id: card.id,
amount: Number(card.amount),
quantity: card.quantity,
images: card.file,
};
});
const data = {
id: user?.userid,
data: myMap,
};
My goal with this data is to merge the arrays (myMap
) that contains same id into one object. How can this be achieved?