Currently, I have a JavaScript object that looks like this:
records: [
{
id: 1,
name: michael,
guid: 12345
},
{
id: 2,
name: jason,
guid: 12345
},
{
id: 3,
name: fox,
guid: 54321
},
{
id: 4,
name: rachel,
guid: 54321
}
];
I am aiming to identify the pairs with matching guids. My idea is to generate a new object that includes both related records. For example:
records: [
{
id: 1,
name: michael,
guid: 12345,
id2: 2,
name2: jason
},
{
id: 3,
name: fox,
guid: 54321,
id2: 4,
name2: rachel
}];
How can I achieve this in JavaScript? Is there a specific function available to merge them directly from the original object without creating another one from scratch? Thank you.