I have an array of objects that might look something like this:
{name: "A", parent: null},
{name: "B", parent: "A"},
{name: "C", parent: "B"},
{name: "D", parent: "B"},
{name: "E", parent: "A"},
here it is in a tree hierarchy:
-A
-B
-C
-D
-E
im trying to remove all items from the array with the name of lets say "B" (this should also remove its children, so in this case items "C" and "D", however Im new to recursion and I was unable to make this work myself, could someone please show me an optimal way of doing this?
thanks to anyone willing to help in advance