I thought that everything was going right in my project, but things didn’t happen as it is written in the 45th step. The image is not changing at all. Please help me understand the error in my code.
Link to the project - https://www.codecademy.com/paths/web-development/tracks/build-interactive-websites/modules/web-dev-interactive-websites/projects/chore-door
Script.js file -
let doorImage1 = document.getElementById('door1');
let botDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/robot.svg";
let doorImage2 = document.getElementById('door2');
let doorImage3 = document.getElementById('door3');
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;
const randomChoreDoorGenerator = () => {
const choreDoor = Math.floor(Math.random() * numClosedDoors);
if (choreDoor === 0) {
openDoor1 = botDoorPath;
openDoor2 = beachDoorPath;
openDoor3 = spaceDoorPath;
} else if (choreDoor === 1) {
openDoor2 = botDoorPath;
openDoor1 = beachDoorPath;
openDoor3 = spaceDoorPath;
} else (choreDoor === 2) {
openDoor3 = botDoorPath;
openDoor1 = spaceDoorPath;
openDoor2 = beachDoorPath;
}
}
doorImage1.onclick = () => {
doorImage1.src = openDoor1;
}
doorImage2.onclick = () => {
doorImage2.src = openDoor2;
}
doorImage3.onclick =() => {
doorImage3.src = openDoor3;
}
randomChoreDoorGenerator();
Please help me understand the error in my code.
Hello 
Here you can find reference dock for if ... else
-> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else.
There is a syntax error in this line:
} else (choreDoor === 2) {
You should remove the condition. Block related to else
will be executed if all the previous conditions are falsy.
Thank you so much for helping !
I have reached the 62nd step. I think something is wrong with my code because ChoreBot is appearing on more than 1 door and the text of start button is not changing to “Game over! Play again?” (if the ChoreBot appears on 1st or 2nd door).
Link to the project - https://www.codecademy.com/paths/web-development/tracks/build-interactive-websites/modules/web-dev-interactive-websites/projects/chore-door
‘script.js’ file -
let closedDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/closed_door.svg";
const isBot = (door) => {
if (door.src = botDoorPath) {
return true;
} else {
return false;
}
}
const isClicked = (door) => {
if (door.src === closedDoorPath) {
return false;
} else {
return true;
}
}
const playDoor = (door) => {
numClosedDoors--;
if (numClosedDoors === 0) {
gameOver('win');
} else if (isBot(door) === true) {
gameOver();
}
}
const randomChoreDoorGenerator = () => {
const choreDoor = Math.floor(Math.random() * numClosedDoors);
if (choreDoor === 0) {
openDoor1 = botDoorPath;
openDoor2 = beachDoorPath;
openDoor3 = spaceDoorPath;
} else if (choreDoor === 1) {
openDoor2 = botDoorPath;
openDoor1 = beachDoorPath;
openDoor3 = spaceDoorPath;
} else if (choreDoor === 2) {
openDoor3 = botDoorPath;
openDoor1 = spaceDoorPath;
openDoor2 = beachDoorPath;
}
}
doorImage1.onclick = () => {
if (!isClicked(doorImage1)) {
doorImage1.src = openDoor1;
playDoor(doorImage1);
}
}
doorImage2.onclick = () => {
if (!isClicked(doorImage2)) {
doorImage2.src = openDoor2;
playDoor(doorImage2);
}
}
doorImage3.onclick =() => {
if (!isClicked(doorImage3)) {
doorImage3.src = openDoor3;
playDoor(doorImage3);
}
}
let startButton = document.getElementById('start');
const gameOver = (status) => {
if (status === 'win') {
startButton.innerHTML = 'You win! Play again?';
} else {
startButton.innerHTML = 'Game over! Play again?'
}
}
randomChoreDoorGenerator();
Ok, definitely, there is a problem.
Problem is in the function isBot
, take a look at the if
statement in this function and figure it out why it always returns true
. You should be able to spot this one 
Because there is an ’ = ’ instead of ’ === ’ in the if statement
I completed the 68th step. But, the doors disappear when I click on them and the text of ‘start button’ is not changing. I think I made an error in 66th, 67th or 68th step.
I changed the position of the ‘startButton’ function. Now the doors are not disappearing but the text of ‘startButton’ is changing and I can still click on additional doors (when the ‘choreBot’ turns up on the door)
There is definitely an error in 66th - 68th step. Because, when I removed the code that was to be written in those steps, the everything was working fine. But, when I added the code of 66th - 68th steps including the 69th step, the doors started disappearing again and the text ‘Game over! Play again?’ is not visible.
I have copied my code below -
let doorImage1 = document.getElementById('door1');
let botDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/robot.svg";
let doorImage2 = document.getElementById('door2');
let doorImage3 = document.getElementById('door3');
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 closedDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/closed_door.svg";
let startButton = document.getElementById('start');
let currentlyPlaying = true;
const isBot = (door) => {
if (door.src === botDoorPath) {
return true;
} else {
return false;
}
}
const isClicked = (door) => {
if (door.src === closedDoorPath) {
return false;
} else {
return true;
}
}
const playDoor = (door) => {
numClosedDoors--;
if (numClosedDoors === 0) {
gameOver('win');
} else if (isBot(door) === true) {
gameOver();
}
}
const randomChoreDoorGenerator = () => {
const choreDoor = Math.floor(Math.random() * numClosedDoors);
if (choreDoor === 0) {
openDoor1 = botDoorPath;
openDoor2 = beachDoorPath;
openDoor3 = spaceDoorPath;
} else if (choreDoor === 1) {
openDoor2 = botDoorPath;
openDoor1 = beachDoorPath;
openDoor3 = spaceDoorPath;
} else if (choreDoor === 2) {
openDoor3 = botDoorPath;
openDoor1 = spaceDoorPath;
openDoor2 = beachDoorPath;
}
}
doorImage1.onclick = () => {
if (currentlyPlaying && !isClicked(doorImage1)) {
doorImage1.src = openDoor1;
playDoor(doorImage1);
}
}
doorImage2.onclick = () => {
if (currentlyPlaying && !isClicked(doorImage2)) {
doorImage2.src = openDoor2;
playDoor(doorImage2);
}
}
doorImage3.onclick =() => {
if (currentlyPlaying && !isClicked(doorImage3)) {
doorImage3.src = openDoor3;
playDoor(doorImage3);
}
}
startButton.onclick = () => {
startRound();
}
const startRound = () => {
doorImage1.src = closedDoorPath;
doorImage2.src = closedDoorPath;
doorImage3.src = closedDOorPath;
numClosedDoors = 3;
startButton.innerHTML = 'Good luck!';
currentlyPlaying = true;
randomChoreDoorGenerator();
}
const gameOver = (status) => {
if (status === 'win') {
startButton.innerHTML = 'You win! Play again?';
} else {
startButton.innerHTML = 'Game over! Play again?';
}
currentlyPlaying = false;
}
startRound();
Execution of your script results in this error (in the dev console):
ReferenceError: closedDOorPath is not defined
at startRound (/script.js:76:20)
at /script.js:91:1
You have to change closedDOorPath
to closedDoorPath
at this line:
doorImage3.src = closedDOorPath;
I am having trouble in the 70th step. After writing what was said in it, I am not able to restart after the game ends (using the start button).
Here is what I did in the 70th step -
if (!currentlyPlaying) {
startButton.onclick = () => {
startRound();
}
}
I understood what was wrong with the code in 70th step. I had to put the if statement inside the ‘startButton.onclick’ function. Thanks for all the help!