I have this array:
[
{
id: 1,
name: 'test 1',
children: []
},
{
id: 2,
name: 'test 2',
children: [
{
id: 4,
name: 'test 4'
}
]
},
{
id: 3,
name: 'test 3',
children: []
}
]
How can I filter by the id property in both this array and the nested children arrays?
For example, searching for id = 3, should return the test 3 object, and searching for id = 4 should return the test 4 object.
childrenarrays fixed to one level, or is it arbitrary?