I have a complex array structure that looks something like this: I am trying to determine the depth of this nested array, focusing on the element with the most deeply embedded children.
let arr = [
{
name: 'tiger',
children: [{
name: 'sinba',
children: [{
name: 'cute',
children: []
}]
}]
},
{
name: 'lion',
children: []
}
]
In this scenario, the maximum depth is 3, as the item tiger
reaches a depth of 3 levels. Therefore, the depth is 3
I have attempted to solve this using recursion, but I am struggling to identify the element with the most nesting level.
Any guidance or assistance would be greatly appreciated.