For further actions, you may consider blocking this person and/or reporting abuse
Read next
![drsimplegraffiti 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%2F616605%2Fbb471769-7514-4d7c-9300-5d1485f626a3.jpg)
Building a TypeScript REST API with an Object-Oriented Programming (OOP) Approach
Abayomi Ogunnusi -
![raajaryan 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%2F996752%2F123dcaa3-e19c-4b01-af1b-73666b290777.jpg)
Exploring CRUD: What It Is and How It Works
RaAj Aryan -
![safdarali 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%2F1351472%2F115e25ba-1733-4356-bf0c-1e5eff57b72f.jpeg)
Several recommended practices for writing good asynchronous JavaScript code
Safdar Ali -
![automq 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%2F1413364%2F9c562138-e04b-4455-8dc3-09a925aff88f.jpg)
How to Achieve 2x Partition Write Performance for Kafka
AutoMQ -
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/