playDoor() is the function which decreases the number of doors remaining, but if you’ve followed the instructions then this should not get called if either the door has already been clicked or the player has lost and the game is over. This is explicitly what it asks for in step 65.
If your game allows the player to continue after they’ve lost, you’ve overlooked some of the logic that the exercise asks for:
Steps 46 - 49 ask you to implement the
playDoor() function, and to have it do the following:
- Decrease the number of unopened doors by 1;
- Check if the win condition has been reached, and call an as-yet-unwritten
Steps 50 - 52 ask you to implement the
isClicked() function to test if a door has been previously clicked.
Step 53 asks you to incorporate the “anti-cheat”
isClicked() function into your
.onclick() handlers for each door, making each of them clickable once only.
Steps 54 - 57 introduce the
gameOver() function, and write the logic for the player achieving the win condition. At this stage, it’s still impossible to lose…
Steps 58 - 61 ask you to expand your code to test whether the player has found the ChoreBot with the
isBot() function, and to add this to your
Step 62 expands the
gameOver() function to tell the player when they’ve lost, but it’s still not possible to lose because…
Steps 63 - 65 ask you to introduce the
currentlyPlaying boolean value which determines whether the game is in progress, and whether your clicks count.