I've found a bug in a recursion challenge

I’ve found a bug in a recursion challenge

I’ve been trying to solve this exercise but it keeps telling me that i need to use recursion… I think I’m using it explicitly.

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 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0.

Challenge: Replace Loops using Recursion

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion

Copy pasted your code and it passes all the tests in the challenge, doesn’t seem to have a problem

are you using firefox? It’s twice that there are posts about this challenge passing only on chrome

This challenge is throwing an error in Firefox.

SyntaxError: invalid regular expression flag s test-evaluator.js:569:3474

I didn’t look into it.

It looks like a fix for this problem is currently in review:

A fix for this has reached the production platform, please check. Happy contributing.

1 Like