I have an array of objects like this:
const data = [{id: 3, name: ''}, {id: 4, name: ''}, {id: 5, name: '', parent: 3}, {id: 6, name: '', parent: 5}, {id: 7, name: '', parent: 4}, {id: 8, name: '', parent: 8}];
Is there a way to create a nested list by appending child elements to their corresponding parent element using <li>
? For example:
<li>
object id:3 (parent)
<li>object id:5</li> (child)
</li>
Any suggestions would be greatly appreciated! :)