Here is a function I wrote in Javascript to illustrate the problem I'm having.
function test(x,depth){
for (n=0;n<x;n++){
console.log(x.toString()+" "+depth.toString()+" "+n.toString())
test(x-1,depth+1)
console.log(x.toString()+" "+depth.toString()+" "+n.toString())
}
}
test(4,0)
here is my console output:
4 0 0
3 1 0
2 2 0
1 3 0
1 3 0
2 2 1
3 1 2
4 0 3
why is the variable n effected by calling test(x-1,depth+1)? n is not passed as a parameter.
Thanks