I need to : check every node in tree start from the root, loop on its node ,check each node if there any child related to that node and call the same function again (recursive function). My code is:
var tree = new Array();
tree[0] = ["Node1", "Node2", "Node3", "Node4"]
tree[1] = ["Node1", "Node2"]
tree[2] = ["Node1", "Node2", "Node4"]
function schTree(treeArr){
//LOOP ON CHILD NODE TO CHECK IF THE NODE IS PARANT FOR SOME OTHER NODE OR NOT and do some actions
for(i=0;i<treeArr.length; i++){
if(treeArr[i].length){
schTree(treeArr[i]);
};
}
}
//call search tree function
schTree(tree);
The problem is : The loop did not complete if I recall the function.
I think that each calling for the function recursively It construct new function above the current function (work on the same place in memory not creating new function)
How to : Make normal recursive function ?????
Thanks in advance
Maged Rawash