Tell us what’s happening:
I think I have the correct code but not sure what kind of output the challenge wants. It says,
Return the final result in an array, with only the door number included in the array if it is open.
I am assuming I need to return an array only with indexes of open doors, am I wrong?
Your code so far
function getFinalOpenedDoors () {
let doors = [];
let finalDoors = [];
for(let i=0; i<100; i++) {
doors.push(false);
}
for(let i=1; i <= 100; i++) {
for(let j=i-1; j < 100; j += i) {
doors[i-1] = !doors[i-1];
}
}
for(let i=0; i<doors.length; i++) {
if(doors[i])
finalDoors.push(i);
}
return finalDoors;
// Good luck!
}
getFinalOpenedDoors();
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge: