Chore Door Project - why is wrong in the last steps

Hello, I am doing the Chore Door exercise and everything was working up until the very end - which was the startButton.onclick and startRound() functions. Those cause all doors to close and remain closed despite include the randomChoreDoorGenerator function. Does anyone see the error??? I’ve been reviewing the last steps and don’t so would appreciate any help. Thanks!

let doorImage1 = document.getElementById("door1") let doorImage2 = document.getElementById('door2'); let doorImage3 = document.getElementById('door3'); let currentlyPlaying = true; 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" doorImage1.onclick = () => { if(!isClicked(doorImage1) && currentlyPlaying) { doorImage1.src = openDoor1; playDoor(doorImage1); } } doorImage2.onclick = () => { if(!isClicked(doorImage2) && currentlyPlaying) { doorImage2.src = openDoor2; playDoor(doorImage2); } } doorImage3.onclick = () => { if(!isClicked(doorImage3) && currentlyPlaying) { doorImage3.src = openDoor3; playDoor(doorImage3); } } let startButton = document.getElementById("start"); startButton.onclick = () => { if(!currentlyPlaying) { startRound() } const startRound = () => { doorImage1.src = closedDoorPath; doorImage2.src= closedDoorPath; doorImage3.src = closedDoorPath; numClosedDoors = 3; currentlyPlaying = true; startButton.innerHTML = "Good luck!" randomChoreDoorGenerator(); } function gameOver(status) { if(status === 'win') { startButton.innerHTML = "You win! Play Again?" } else { startButton.innerHTML = "Game over! Play again?" } currentlyPlaying = false; } let numClosedDoors = 3; let openDoor1; let openDoor2; let openDoor3; const randomChoreDoorGenerator = () => { let choreDoor = Math.floor(Math.random() * numClosedDoors) if(choreDoor<1) { openDoor1=botDoorPath; openDoor2 = beachDoorPath; openDoor3 = spaceDoorPath; } else if(choreDoor>=1 && choreDoor<2) { openDoor1 = spaceDoorPath; openDoor2=botDoorPath; openDoor3 = beachDoorPath; } else { openDoor1 = beachDoorPath; openDoor2 = spaceDoorPath openDoor3=botDoorPath; } } let closedDoorPath = "https://content.codecademy.com/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; } return true; } const playDoor = (door) => { numClosedDoors --; if(numClosedDoors === 0) { gameOver('win') } else if(isBot(door)) { gameOver(); } } startRound()

Hi,
if you run the codebyte, it tells you that you have a syntax error: Unexpected end of script.
That usually means that you have a scope error caused by a missing bracket. This is also the case in this code. So check all your functions: Are they closed properly?

Gosh that was it. It was driving me crazy. Thanks!

1 Like