Explain this recursion function

Can someone please explain to me how this function works, in steps?

  **Your code so far**
  function multiply(arr, n) {
    if (n <= 0) {
      return 1;
    } else {
      return multiply(arr, n - 1) * arr[n - 1];
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36

Challenge: Replace Loops using Recursion

Link to the challenge:

A lot of people have already given explanations for this, so I won’t try to do that now. Here’s a good explanation. Replace Loops using Recursion -1 explanation - #56 by JeremyLT

1 Like

@jonathan.roley thank you so much, for the link.

No problem, glad I could help!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.