Tell us what’s happening:
Hi, I am really stuck with this one. Though I understand recursion through other examples, I can’t figure out how this example works.
What is happening in the line below between the two parameters arr and n-1? What is being multiplied ? What makes me confused is that the function has two paramenters: arr and n. I don’t understand their relationship here.
return multiply(arr, n - 1) * arr[n - 1];
Thanks for any help, really appreciated!
Your code so far
function sum(arr, n) {
// Only change code below this line
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
.
Challenge: Replace Loops using Recursion
Link to the challenge: