I'm having trouble generating a function responsible for traversing and returning a hierarchical tree.
Follow JavaSript / JSON code:
let tree = {
label: 'Elemento A',
itens: [
{
label: 'Elemento A1',
itens: [
{
label: 'Elemento A1a',
itens: [
{
label: 'Elemento A1a1'
},
{
label: 'Elemento A1a2'
}
]
},
{
label: 'Elemento A1b'
}
]
},
{
label: 'Elemento A2',
itens: [
{
label: 'Elemento A2a'
},
{
label: 'Elemento A2b'
}
]
}
]
}
I need a recursive function to traverse this Array -.- '