I have an array as below:
original = [
{
id:1,
value1 : 500
},
{
id:1,
value2 : 600
},
{
id:2,
value1 : 700
},
{
id:3,
value2 : 750
}
];
I want to merge the duplicate objects in the above array and want the final output array as below:
finalArr = [
{
id:1,
value1:500,
value2:600
},
{
id:2,
value1:700,
value2:null
},
{
id: 3,
value1: null,
value2:750
}
];
How can I achive this using JavaScript or TypeScript?