**Tell us what’s happening:**

let sum([2,3,4],3);

return sum(arr,n-1)+arr[n-1];//How it returns number 9.

note :i know 9 is sum of first three elements of array.But i really don’t know how it came,i tried by analyze like this, sum([2,3,4],2)+arr[2]; //since n=3;

can anybody answer me.please correct me if i wrong.

**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 (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:**