How can I build an object from a file path? [duplicate]
This question already has answers here: Create nested object from array of objects based on path property (1 answer) Create nested object from multiple string paths (2 answers) Javascript: how to dynamically create nested objects using object names given by an array (26 answers) Closed 4 days ago. The community is reviewing whether to reopen […]
I’m unable to create a recursion to build a tree based on a flat array
const arr = [ { id: 1, name: ‘teste’, }, { id: 2, name: ‘teste’, dependsOn: 1, }, { id: 3, name: ‘teste’, dependsOn: 1, }, { id: 4, name: ‘teste’, }, { id: 5, name: ‘dasdas’, dependsOn: 2 }, ] const treeTo = [ { id: 1, name: ‘teste’, children: [ { id: 2, […]
Recursion not resolving all the way back up (JavaScript)
I am currently trying to create a function that will take a position in the game of Tik-Tac-Toe and create a tree of all possible games from that position. The problem is that when I call the function it does not seem to resolve all the way back up.