Replace Loops using Recursion

Tell us what’s happening:
Hello, I can’t get the last test to pass: “You should use recursion to solve this problem.” I tried the code from the hint as well, but no luck. Do you have any idea why? Thanks.

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:69.0) Gecko/20100101 Firefox/69.0.

Challenge: Replace Loops using Recursion

Link to the challenge:

are you using firefox? there was an other user that wasn’t able to make the code pass on firefox but worked on google chrome

1 Like

Worked in chrome. Thank you.