100 Doors Answer Is Not Valid

It works fine in console, but this answer is not valid. Please, help figure out what is wrong.

function getFinalOpenedDoors (numDoors) {
  // Good luck!

  let doors = [];

  for (let i = 0; i < 100; i++) {
    doors[i] = false;
  }

  for (let i = 1; i <= 100; i++) {
    for (let j = 1; j <= 100; j++) {
      if (!(j  % i)) {
        doors[j] = !doors[j];
      }
    }
  }

  doors = doors.filter((element) => element);

  return doors;
  
}

getFinalOpenedDoors(100);

The instructions say

Return the final result in an array, with only the door number included in the array if it is open.

Logging your solution gives an array like this - [true, true, true, true, true, true, true, true, true, true]

So I’m thinking it needs to be an array with all the open doors… something like this - [1,7,15...]

1 Like

Thank you. I misunderstood.