Can someone explain the output for this recursive function? Thank you!
function test(a) {
while (a > 0) {
a -= 1;
test(a);
console.log('after first invocation: ' + a);
}
}
test(3);
Output:
after first invocation: 0
after first invocation: 1
after first invocation: 0
after first invocation: 2
after first invocation: 0
after first invocation: 1
after first invocation: 0
Well the code does 100% what you tell him to do!
I don’t think i have to do it for every output but I think you get the point?