Recursive Function Not Ending On A Return Statement?
I'm going through eloquent javascript & this recursive function has me stumped, I understand most of it. function findSolution(target) { function find(current, history) {
Solution 1:
Because of this:
return find(current + 5, `(${history} + 5)`) ||
find(current * 3, `(${history} * 3)`);
When the function called at the left part of the OR returns a null, it evaluates to false, so the second part is evaluated, and the function is called again
Post a Comment for "Recursive Function Not Ending On A Return Statement?"