I have an array that looks like the following:
[
{
"id": "denuzi",
"sub":
[
{"id": "s4p58o"},
{"id": "xzbqi"},
],
},
{
"id": "4rcodm",
"sub": [],
}
]
What I am trying to do is remove an item from the array or from a nested array using a provided id.
e.g. if denuzi is provided then the entire first object is removed; if s4p58o is provided just that object from the first objects sub array is removed.
I know that I can remove an entire object with the following code:
_.remove(this.items, function(item) {
return item.id !== id;
});
But I am not sure how to make a check to remove a sub item?