function sum(arr, n) {
// Only change code below this line
if (n <= 0) {
return 0;
} else {
return sum(arr,n - 1) + [n - 1];
}
// Only change code above this line
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0
I’m talking about just the [n - 1]. There is no return there. n - 1 is just a number inside of a set of brackets. What does a number inside of a set of brackets mean?
Yup. You made an array there. But sum(arr, n - 1) is a number. You can’t add an array and a number.
You can add a number and a number though. If you have the sum of the first 5 elements of an array, what should you add to that sum to get the sum of the first 6 elements of the array?
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.