Recursion - adding all array numbers

Tell us what’s happening:
People,
I have put arr[n+1] for it to add the next number in the array at each time it executes the recursion loop, but don’t understand why it doesn’t add all the n numbers. Any tips?

Your code so far

  function sum(arr, n) {

// Only change code below this line

if(n==0){
return 0;
}
else if(n==1){
return arr[0];
}
else{
return sum(arr,n)+arr[n+1];
}
// 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/83.0.4103.116 Safari/537.36.

Challenge: Replace Loops using Recursion

Link to the challenge:

I’d recommend putting a console.log of the return value each time the function loops. That way, you can see why it doesn’t add all the n numbers.

I have done it but it still sounds kind of confusing, i guess the if n=0 is the stop the sum