Can anyone help me with the tree diagram or stack diagram of function call countup(5)
so that i can understand better how it is actually working behind scene.
Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.
How variable const countArray is keeping reference of function countup(n - 1)?. Since it being called n-1 times, what is actually happening behind scene.
is Global Frame = Execution Stack ? in JavaScript ES5 ?
On the top of stack countup(0) will be there and it will return [];.Countup(0) will be popped. Then on top of stack countup(1) will be there tell me how 1 is pushed in empty array[] ?
after countup(0) returns [] (so that is the value assigned to countArray), n (which has value of 1 in this case) is pushed to countArray, so now countArray is [1]