I have two arrays as input (array1 & array2) for which I want to check if there is a match on id. If there is a match they should be included in a new array called result.
array1 = [
{ x_id:6711230070958, id:279482 },
{ x_id:6770878283950, id:213 },
{ x_id:6753301168302, id:330120 }
];
array2 = [
{ id: 279482, stock: 9 },
{ id: 31231, stock: 2 },
{ id: 330120, stock: 2 }
];
result [
{ x_id:6711230070958, id: 279482, stock: 9 },
{ x_id:6753301168302, id: 330120, stock: 2 }
]
For finding the matches I tried using a filter with includes. Anybody some thoughts on this?