"Replace Loops using Recursion" not working

Tell us what’s happening:
Describe your issue in detail here.

I cannot pass this exercise. I did it correctly, and even copy pasting the solution, even though the same, will not pass the test. Is this a bug?

  **Your code so far**

function sum(arr, n) {
// Only change code below this line


function sum(arr, n) {
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/92.0.4515.131 Safari/537.36 Edg/92.0.902.73

Challenge: Replace Loops using Recursion

Link to the challenge:

You copy-pasted the solution inside of your code in a way that breaks the code.

I recommend starting over and asking questions about recursion instead of copying the answer.

What part is tripping you up? What did you try before you tried to copy the answer?

The code I typed was identical to the solution, that is why I tried copy and pasting to make sure I didn’t have a typo somewhere.

On second examination however, I completely missed that part of the code (above the //only change code below this line, and below //only change code above this line) was already written in and I ended up typing the function name again.

Silly me. Thank you for the reply anyways!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.