This code seems to have the correct output in Repl.it and in the freeCodeCamp console, but it’s unable to pass tests 2 and 3. I am using Chrome. Thanks for any help.
//Only change code below this line
function countdown(myArray, n){
var num = n;
if (n <= 0) {
if (n === -1) {
return [];
}
else {
return myArray.concat([]);
}
}
else {
var newArr = countdown(myArray, n - 1);
newArr.splice(myArray.length, 0, num);
return newArr;
}
}
console.log(countdown([10, 12], 5));
this is a recursion lesson
what bassicly is recursion is the next
1
1 1+
1 1+ 1++
our negative
10
10 10-
10 10- 10–
they also asking u to make a countdown
using the number that must include 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
but without using loops.
does your code equals that?