ChoreDoor Issue

I’m working through the Chore Door project for JavaScript Interactive Website, and I’m stuck on one of the steps.

I have the following code:
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”;

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

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

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

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

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

randomChoreDoorGenerator();

When i click on the doors, the images don’t change. I can’t seem to find the issue in the functions that’s breaking it.

Thanks in advance

I see what my issue was. I had an extra = in my else if statement

2 Likes