/*
n = 2;
2 is not <= 0;
else block return multiply([2, 3, 4], 1) * 3;
so does it call the function now with multiply([2, 3, 4], 1)?
multiply([2, 3, 4], 1);
n = 1;
1 is not <= 0;
else block return multiply([2, 3, 4], 0);
calls multiply([2, 3, 4], 0) which we know returns 1;
so now we have return multiply([2, 3, 4], 1) * arr[0];
so that is 1 * 2;
so it returns 2;
then we multiply that return 2 * 3;
it returns 6;
please tell me I did this right lol */
Yes, that is the very definition of a recursive function, it calls itself.
And I think you got it!
1 Like
Thank you again for walking me through this. I have tried it with different numbers and sometimes I get it right, other number combinations seem to be more difficult. overall I think I grasp the concept… I think lol. I will keep practicing.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.