Need recursion challenge breakdown help?

Tell us what’s happening:
Describe your issue in detail here.
In the text explaination of the challenge I don’t understand where how they evaluated the function. How did they come up with, multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1] from,

 function multiply(arr, n) {
    let product = 1;
    for (let i = 0; i < n; i++) {
      product *= arr[i];
    }
    return product;
  }
  **Your code so far**

function sum(arr, n) {
// Only change code below this line

// Only change code above this line
}
//1 x n (stops when the index of arr is less than n)
//[4,6,8,6]
/* 1 * where n is first element so means i has to be less than 1 

  **Your browser information:**

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

Challenge: Replace Loops using Recursion

Link to the challenge:

I’m not sure what you mean by “how they evaluated the function”.

The relationship multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1] is saying that "the product of the first n elements of arr" is the same thing as "the product of the first n-1 elements of arr" multiplied by "the nth element of arr".

The “big idea” with recursion is that the problem is broken down into a smaller version. In this case, multiply n elements of arr is replaced with the easier task of "multiply n-1 elements of arr" until we get to the “base case” of "multiply 0 elements of arr".

1 Like

sorry wrote the question up pretty fast, but yes that is exactly the answer I needed. Helps so much. Thank you!!!