I have a problem with the task. I would like the easiest way to get the result, which is a tree with all the elements.
The object looks like this:
const bookPages = [
{
name: '1',
content: [
{
name: '1.1',
content: [
{
name: '1.1.1',
content: []
}
]
},
{
name: '1.2',
content: []
}
]
},
{
name: '2',
content: [
{
name: '2.1',
content: []
}
]
}
]
console.log(bookPages);
After typing this to the console I would like to get a similar result:
// - 1
// -- 1.1
// --- 1.1.1
// -- 1.2
// -2
// --2.1
WHAT would be the easiest way to do it? Thanks