Javascript Tree (Array of object) Traversal with Ancestors
I am trying to make a tree traversal function in javascript. I also want ancestors of any nodes. That's why I have written code like this: const visit = (tree) => { if (!typeof ancestors){ const ancestors = [] }…