How to remove selected item and nested item too from array using javascript
function filterID(id, data) {
return data.reduce((arr, item) => {
if (item.id != id) {
if (item.children) item.children = filterID(id, item.children)
arr.push(item)
}
return arr
}, [])
}
https://jsfiddle.net/p5fxhcbk/1/
Please help on this
Thank You
it should also removed JZLS37EVZQM22H9Q4659 item as well since it is child element of JZLS37EVZQM22H9Q4655