I'm helping someone on his school assignment - we're trying to write recursive function (if it matters - either in PHP or JavaScript).
I understand principles of recursion quite well, but I haven't wrote any of those from "academic" viewpoint.
Is it good practice to use global variable to store result, something like:
var results = [];
var rec = function(a) {
...
if (match)
results.push(someValue);
}
Or should I use return for collecting all those results back together (which would be much more difficult)?