Getting the right results, not passing the tests on 100door

Tell us what’s happening:
Hi, I’m a bit confused why is this not passing the tests, not even for returning an array when I seem to be getting the right results when I checked it in console.

Your code so far


function getFinalOpenedDoors(numDoors) {

let allDoors=[];
let result=[];
for(i=0; i<numDoors; i++){
allDoors.push(false)
}
let iterator=1
while(iterator<=allDoors.length){
for(let i=iterator-1;i<allDoors.length;i+=iterator){
 
if(allDoors[i]){
allDoors[i]=false
} else{
allDoors[i]=true
}
}
iterator++;
}
for(let i=0;i<allDoors.length;i++){
if(allDoors[i]){
  result.push(i+1)
}
}
return result


}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.

Challenge: 100 doors

Link to the challenge:
https://www.freecodecamp.org/learn/coding-interview-prep/rosetta-code/100-doors

What is the error message you are receiving? Sometimes you not only have to create the expected result but you also need to some in a certain way expected by the challenge.

That solved it! Thank you