For further actions, you may consider blocking this person and/or reporting abuse
See why 4M developers consider Sentry, “not bad.”
Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.
Read next

🎯Starting My 100-Day Coding Challenge with Express.js
Sahil khatiwada -

How to Add Page Transition in Next.js🧑💻🌠
Arindam Majumder -

React Best Practices with Examples
Philip Walsh -

Building a Word Guessing Game Using HTML, CSS, and JavaScript
sharathchandark -
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/