i am trying to create a multidimensional array from a flat array. but i somehow i can not figure it out.
I manage it to get it 1lvl deep but can not figure out how to go all the way: example :
[
{ id: 'cG9zdDoyODI=', parentId: null, children: [] },
{ id: 'cG9zdDoyODM=', parentId: null, children: [] },
{ id: 'cG9zdDoyODc=', parentId: null, children: [] },
{ id: 'cG9zdDoyODY=', parentId: 'cG9zdDoyODc=', children: [] },
{ id: 'cG9zdDozMDE=', parentId: 'cG9zdDoyODY=', children: [] },
{ id: 'cG9zdDozMDI=', parentId: 'cG9zdDozMDE=', children: [] },
{ id: 'cG9zdDoyODQ=', parentId: 'cG9zdDoyODc=', children: [] },
{ id: 'cG9zdDoyODU=', parentId: 'cG9zdDoyODc=', children: [] }
]
i am trying to place each object that has a parent into the parents children array.
all the help is welcome, thanks in advance