100 doors for help

Tell us what’s happening:
I can’t pass the challenge and I wonder if there is any problem.

Your code so far


function getFinalOpenedDoors (numDoors) {
  let status=[];
  let opened_doors=[];
  for(let numdoor=1;numdoor<=numDoors;numdoor++){ 
    status[numdoor] = 1;  // 1=open   -1=close
  }

  for(let times=1;times<=100;times++){  //the times of visiting the 100 doors
    for(let numdoor=1;numdoor<=numDoors;numdoor++){ //the num of every door
      if(numdoor%(times)==0){
        status[numdoor]=-status[numdoor];        
      }
    }
  }
  
  for(let numdoor=1;numdoor<=numDoors;numdoor++){ 
    if (status[numdoor]==1) {  //recording the num of opened door
      opened_doors.push(numdoor);
    }
  }

  return opened_doors;
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36.

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

Without really reading your code, the instructions says that all doors are initially closed.

Well it seems to me you’re doing the opposite:

status[numdoor] = 1; // 1=open -1=close

Thank u ,simple but useful.