Your code contains global variables that are changed each time the function is run. This means that after each test completes, subsequent tests start with the previous value. To fix this, make sure your function doesn’t change any global variables, and declare/assign variables within the function if they need to be changed.
Example:
var myGlobal = [1];
function returnGlobal(arg) {
myGlobal.push(arg);
return myGlobal;
} // unreliable - array gets longer each time the function is run
function returnLocal(arg) {
var myLocal = [1];
myLocal.push(arg);
return myLocal;
} // reliable - always returns an array of length 2
Yes agreed with @ilenia If I want to put in other way such you can understand that whenever you run the function countdown(10) the array arr becomes [10,9,8,7,6,5,4,3,2,1]. So if you would again run this function countdown(10) this would return [10,9,8,7,6,5,4,3,2,1,10,9,8,7,6,5,4,3,2,1] which would not pass the test. So put it simply your function should return same value on same input. Hope this helps