Answer the question
In order to leave comments, you need to log in
Why would return in recursion return undefined?
Why would return in the first example return undefined - https://jsfiddle.net/slavik_210/Lwp0bgr1/1/ ?
And if the result is saved to an external variable, then it works - https://jsfiddle.net/slavik_210/7x95ydjh/
Answer the question
In order to leave comments, you need to log in
The result of the recursion must also be returned:
if(list[i].children) {
return getChildLists(list[i].children, name);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question