This commit is contained in:
Your Name committed 2026-06-16 20:04:40 -04:00
1 parent b8873f88b0
commit 807c43ece5
9 files changed
+624 -259

No files matched your search

+8 -1
View File
@@ -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);