Looking for a way to remove elements in an array based on their relationships with each other?
For example:
const array = [
{
id: 14098,
parent: 14096,
},
{
id: 14100,
parent: 0,
},
{
id: 14096,
parent: 14100,
},
];
The task at hand involves iterating through the array and deleting the parent element. In doing so, all child elements associated with that parent should also be removed... and even child elements of those child elements.
Any suggestions on how to approach this?
Best regards,
Ricardo