Tell us what’s happening:
first of all: I am aware that whether or not I solve this specific issue maybe my algorithm doesn’t solve the challenge (if you have suggestions about this go head). Having said that:
if I run this myArray is not defined Your code so far
function countdown(myArray, n){
return n <= 0
? myArray.unshift(n)
: countdown(myArray.unshift(n), n-1 )
}
countdown(myArray, 10);
if I run this:
function countdown(myArray, n){
let myArray = [];
return n <= 0
? myArray.unshift(n)
: countdown(myArray.unshift(n), n-1 )
}
countdown(myArray, 10);
the message is that myArray has already been declared.
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.107.
it’s this one that is not defined. the tests use a myArray of their own, but if you just copy the tests it will not work because you don’t have a myArray variable.
to simulate that you can add const myArray = [] before calling the function