x
This commit is contained in:
1 parent
b8873f88b0
commit
807c43ece5
9 files changed
+624
-259
No files matched your search
@@ -1 +1,8 @@
|
||||
console.log('hello ts')
|
||||
const tree = [{ nodeId: "root1" }, { nodeId: "root2", links: [] }];
|
||||
function findNodeAndParent(tree: any[], targetId: string, parent: any = null, list: any[] = tree): any {
|
||||
for (let i = 0; i < tree.length; i++) {
|
||||
if (tree[i].nodeId === targetId) return { node: tree[i], parent, list, index: i };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
console.log(findNodeAndParent(tree, "root1").parent === null);
|
||||
Reference in new issue
Block a user