This is a follow up of Pushing an object into array where I was pushing an object into the array by identifying the parentActivityId. Now I wanted to remove the object based on its id.I have tried the below code based on the follow up question but its not working.Can anyone tell me what I'm doing wrong here?
function getParent(r, a) {
return a.id === child.parentActivityId ? a : a.items.reduce(getParent, r);
}
var node = data.reduce(getParent, {});
'items' in node && node.items.splice(child,1);