I’m stuck on this challenge:

Write a recursive function, `sum(arr, n)`

, that returns the sum of the first `n`

elements of an array `arr`

.

I need to achieve this:

`sum([2, 3, 4, 5], 3)`

should equal 9.

**My code so far:**

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

**Challenge:** Replace Loops using Recursion

**Link to the challenge:**