ILM
October 21, 2019, 8:16pm
2
have you checked the explanations on those other threads? did you not understand the explanations there?
these are two explanations I wrote in the last two days. does this help?
the first value returned is an array because when the following is reached then the function doesn’t call itself anymore but return a value.
The second to last function call has a value for its numbers variable, which is an array (as that is what count(1) has returned). So now n which in this iteration is 2 is pushed, the array is returned and count(2) has an output, and so on till the process reaches the first function call
the function keeps calling itself till it reaches this, then the last function call has an output, which is then used to the second last to give a value to the numbers variable, then the array has the push method called on, and is then outputted by the function, the third to last call uses this array to give a value to his numbers variable and so on
1 Like