Tell us what’s happening:
I think the code is buggy, since i am using recursion and it is still asking me to use recursoin in order to get the lesson.
by the way thanks to the creators of this site for including extra lessons.
Your code so far
js
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.15; rv:69.0) Gecko/20100101 Firefox/69.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