For further actions, you may consider blocking this person and/or reporting abuse
Read next
7 Most Popular JavaScript Front-End Frameworks in 2024 Visualized with Graphs ππ
Thomas U -
![codewithshan profile image](https://media.dev.to/cdn-cgi/image/width=100,height=100,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F367483%2Fdfe66f1c-3d70-4d4e-b05c-501b6c9a20b4.jpg)
Remove Object from Array using JavaScript Filter (Easy Tutorial)
Shan Asif -
![durgesh_chaudhari_04 profile image](https://media.dev.to/cdn-cgi/image/width=100,height=100,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1985965%2F06b11486-c984-4755-b38f-e26d98c75559.jpg)
Integrating AI into My Recipe Recommender MERN Project: Seeking Your Input and Ideas
Durgesh Chaudhari -
![kostyatretyak profile image](https://media.dev.to/cdn-cgi/image/width=100,height=100,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F398023%2F5deaa82a-162c-4f3e-a075-99469a954954.jpg)
A quick overview of Bun's basic features and how it compares to Node.js
ΠΠΎΡΡΡ Π’ΡΠ΅ΡΡΠΊ -
Top comments (2)
Because what you have here is a doubly linked tree, you have a choice how you want to populate the tree. I think it would be easier attaching children to their parents.
What I would do is:
children
(it's because the name childrenID suggest, that it has something to do with ID, not the children themselves)parentID
from the lookup map and push it at the end of thechildren
arrayparentID: null
. You could use.filter
for this.For better efficiency, you could bundle points 2, 3 and 4 into one.
Good luck!
I FOUND A SOLUTION - jsfiddle.net/cw9rq7ht/6/