We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c8c693 commit aa5079dCopy full SHA for aa5079d
find-node.js
@@ -1,23 +1,20 @@
1
+const findNode = (tree, value) => {
2
+ let found = false;
3
-const findNode = (tree,value) => {
-
4
- let found = false ;
5
6
- if (tree.value === value) {
7
- return true;
8
- }
+ if (tree.value === value) {
+ return true;
+ }
9
10
- for(var index=0;index< tree.children.length;index++) {
11
- const element = tree.children[index];
12
- found = findNode(element,value);
13
- if(found){
14
- break;
15
16
- };
17
18
- return found;
19
-}
+ for (var index = 0; index < tree.children.length; index++) {
+ const element = tree.children[index];
+ found = findNode(element, value);
+ if (found) {
+ break;
20
+ return found;
+};
21
22
/* example tree
23
0 commit comments