STUCK Chore Door

Dear all!

Right now im trying to go trough the ChoreDoor project. So far everything was working and my code was just fine. I arrived at task 45, and the doors are not opening. I tried everything, checked the walktrough video and it’s code, it’s the same as mine but in the video it is working for me it is not… what a joke…

" let doorImage1 = document.getElementById(‘door1’);

let doorImage2 = document.getElementById(‘door2’);

let doorImage3 = document.getElementById(‘door3’);

let botDoorPath = “https://content.codecademy.com/projects/chore-door/images/robot.svg

let beachDoorPath = “https://content.codecademy.com/projects/chore-door/images/beach.svg

let spaceDoorPath = “https://content.codecademy.com/projects/chore-door/images/space.svg

let openDoor1;

let openDoor2;

let openDoor3;

numClosedDoors = 3;

const randomChoreDoorGenerator = () => {

let choreDoor = Math.floor(Math.random() * numClosedDoors);

if (choreDoor === 0){

openDoor3 = botDoorPath;

openDoor2 = beachDoorPath;

openDoor1 = spaceDoorPath;

} else if (choreDoor === 1) {

openDoor1 = botDoorPath;

openDoor2 = beachDoorPath;

openDoor3 = spaceDoorPath;

} else (choreDoor === 2) {

openDoor2 = botDoorPath;

openDoor3 = beachDoorPath;

openDoor1 = spaceDoorPath;

}

}

doorImage1.onclick = () => {

doorImage1.src = openDoor1;

} //this functions works for the first image, changes the first global variables src to butDoorPaths src.

doorImage2.onclick = () => {

doorImage2.src = openDoor2;

}

doorImage3.onclick = () => {

doorImage3.src = openDoor3;

}

randomChoreDoorGenerator();"

This is my code… Do you have any idea what could cause the error for me? I’m really stuck with this. Got no any idea…

Your Code:

let doorImage1 = document.getElementById('door1');
let doorImage2 = document.getElementById('door2');
let doorImage3 = document.getElementById('door3');
let botDoorPath = "https://content.codecademy.com/projects/chore-door/images/robot.svg"
let beachDoorPath = "https://content.codecademy.com/projects/chore-door/images/beach.svg"
let spaceDoorPath = "https://content.codecademy.com/projects/chore-door/images/space.svg"
let openDoor1;
let openDoor2;
let openDoor3;
numClosedDoors = 3;

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

doorImage1.onclick = () => {
  doorImage1.src = openDoor1;
} //this functions works for the first image, changes the first global variables src to butDoorPaths src.

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

doorImage3.onclick = () => {

  doorImage3.src = openDoor3;

}

randomChoreDoorGenerator();

Your code will fail to run because you, in your final conditional branch, try to specify a condition on an else block. Either change this to an else if block, or remove the condition.

1 Like