I'm dealing with a nested array of objects structured like this:
const nestedArray = [
[{ id: 1 }, { id: 2 }, { id: 3 }],
[{ id: 1 }, { id: 2 }],
[{ id: 4 }, { id: 5 }, { id: 6 }],
]
In the case where objects with id 1 and 2 are already grouped together within the first element of nestedArray
, my goal is to remove the second element while keeping all other elements unchanged. The desired outcome should be as follows:
const nestedArray = [
[{ id: 1 }, { id: 2 }, { id: 3 }],
[{ id: 4 }, { id: 5 }, { id: 6 }]
]
How can I implement a filter function based on the object's id
to achieve this expected result?