I’m having trouble understanding how this statement is true: However, notice that multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1]. Appreciate any help

**Your code so far**

function sum(arr, n) {
// Only change code below this line
if (n <= 0) {
return 0;
} else {
return sum(arr, n - 1) + arr[n - 1];
}
// Only change code above this line
}

**Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0

Challenge: Basic JavaScript - Replace Loops using Recursion

Thank you, I have tried to figure it out with the video lessons on recursion, base case, etc. I guess mathematically I just don’t understand how they’re the same

This is a good question. Remember that the array stays the same the entire time. So the value at the 0th index in the array is always 2, the value at the 1st index in the array is always 3 and the value at the 2nd index in the array is always 5. Now look at the end of the right formula:

* arr[n-1]

So we are multiplying by arr[n-1].

What is the value of n in the left forumla?

multiply([2, 3, 5], 2)

Once you know the value of n in the left formula then you know what arr[n-1] equals in the right formula.

What value are you getting for each side? Can you explain how you got those values? Providing us as much information as possible will help us help you.

Wait, maybe I got it, on left side of equation I’m getting 6 (by multiplying the first two elements). On the right side I’m getting 6 by multiplying the first element(2) by 3.