Https://www.codecademy.com/courses/build-interactive-websites/projects/chore-door

Up to this point, the doors won’t open even when it’s clicked.
I can’t seem to find the problem.
https://www.codecademy.com/courses/build-interactive-websites/projects/chore-door

let doorImage1 = document.getElementById('door1');

let doorImage2 = document.getElementById('door2');

let doorImage3 = document.getElementById('door3');

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";

let numClosedDoors = 3;
let openDoor1;
let openDoor2;
let openDoor3;

let randomChoreDoorGenerator = () => {
  let choreDoor =Math.floor(Math.random() * numClosedDoors);
  if (choreDoor === 0){
    openDoor1 = botDoorPath;
    openDoor2 = spaceDoorPath;
    openDoor3 = beachDoorPath;
  } else if (choreDoor === 1){
    openDoor2 = botDoorPath;
    openDoor1 = spaceDoorPath;
    openDoor3 = beachDoorPath;
  } else (choreDoor === 2){
    openDoor3 = botDoorPath;
    openDoor1 = spaceDoorPath;
    openDoor2 = beachDoorPath;
  }
};

door1.onclick = () => {
  doorImage1.src = openDoor1;
};

door2.onclick = () => {
  doorImage2.src = openDoor2;
};

door3.onclick = () => {
  doorImage3.src = openDoor3;
};

randomChoreDoorGenerator();

using the dev tools, you can check the console for any errors:

Uncaught SyntaxError: unexpected token: script.js:28:26

which tells you have an error on line 28:

else (choreDoor === 2){

which make sense. else is everything else, so you can’t use a condition here.

1 Like

Thank you! This helped me so much I was stuck because of this for an hour. I’ll try use the console more now!