Chore Door project

Hey there. I have an issue with the project Chore Door on the platform. I don’t have any clue what I’m doing wrong. My startButton don’t change (from “Good luck” to " You win! Play again?" even if I created a global variable and used a DOM method (innerHTML). My problem is in steps 54 - 57 i think.

let doorImage1 = document.getElementById('door1');
let doorImage2 = document.getElementById('door2');
let doorImage3 = document.getElementById('door3');
let startButton = document.getElementById('start');
let botDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/robot.svg';
let beachDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/beach.svg';
let spaceDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/space.svg';
const numClosedDoors = 3;
let openDoor1; 
let openDoor2; 
let openDoor3;
const closedDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/closed_door.svg';
//let startButton = document.getElementById('start');
const isClicked = (door) => {
if (door.src === closedDoorPath) {
  return false;
} else {
  return true;
}
}
const playDoor = () => {
 numClosedDoors-- 
  if (numClosedDoors === 0) {
    gameOver('win');
  }
} 
const randomChoreDoorGenerator = () => {
const choreDoor = Math.floor(Math.random() * numClosedDoors);
if (choreDoor === 0) {
openDoor1 = botDoorPath;
openDoor2 = spaceDoorPath;
openDoor3 = beachDoorPath;
} else if (choreDoor === 1) {
openDoor2 = botDoorPath;
openDoor1 = beachDoorPath;
openDoor3 = spaceDoorPath;
} else {
openDoor3 = botDoorPath;
openDoor2 = beachDoorPath;
openDoor1 = spaceDoorPath;
}

}
doorImage1.onclick = () => {
if(!isClicked(doorImage1)) {
doorImage1.src = openDoor1;
playDoor();
}
}

doorImage2.onclick = () => {
if(!isClicked(doorImage2)) {
doorImage2.src = openDoor2;
playDoor();
}
}

doorImage3.onclick = () => {
if(!isClicked(doorImage3)) {
doorImage3.src = openDoor3;
playDoor();
}
}

const gameOver = (status) => {
  if (status === 'win') {
    startButton.innerHTML = 'You win! Play again?';
  };


Here is also a link: https://www.codecademy.com/paths/web-development/tracks/build-interactive-websites/modules/web-dev-interactive-websites/projects/chore-door
Thank you for any help!

Try running your code with your browser console open. You’ll see an error message that should help. After which you should see another error message that will also help.

1 Like

Thank you very much! :slight_smile:

1 Like