Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Dec 9, 2023
1 parent c91f8b0 commit 27b94b8
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Node {
constructor(name) {
this.name = name;
this.children = [];
}

addChild(name) {
this.children.push(new Node(name));
return this;
}

depthFirstSearch(array) {
array.push(this.name);
for (let child of this.children) {
child.depthFirstSearch(array);
}
return array;
}
}

0 comments on commit 27b94b8

Please sign in to comment.