Where does the array get created after the else statement?
My question is how does javascript know arr is an array? is calling unshift on a variable going to immediately turn that const into an array?
**Your code so far**
// Only change code below this line
function countdown(n){
if (n > 1) {
return [];
} else {
const arr = countdown(n - 1);
arr.unshift(n);
console.log(arr)
return arr;
}
}
// Only change code above this line
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
.
Challenge: Use Recursion to Create a Countdown
Link to the challenge: