Help with Chore Door project

Hi I can’t find the bug in this project. Coud anyone point me in right directtion please?

Thanks

const doorImage1 = document.getElementById('door1');
const doorImage2 = document.getElementById('door2');
const doorImage3 = document.getElementById('door3');

let startButton = document.getElementById('start');

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 closedDoorPath = 'https://content.codecademy.com/projects/chore-door/images/closed_door.svg';

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

// Define game logic to check doors, progress game, end game, and choose a random chore door
 const isClicked = (door) => {
   if (door.src===closedDoorPath) {
     return true;
   } else {
   return false;
 }
 }
const isBot = (door) => {
   if (door.src===botDoorPath) {
     return true;
   } else {
   return false;
 }
}
let gameOver = (status) => {
if (status==='win') {
  starButton.innerHTML ="You win! Play again?"
} else starButton.innerHTML ='Game over! Play again?'
}

const playDoor = (door) => {
  numClosedDoors--; 



if (numClosedDoors===0) {
  gameOver('win'); 
} else if (isBot(door)) {
   gameOver('loose');
 } 
}

const randomChoreDoorGenerator = () => {
  choreDoor = Math.floor(Math.random()*numClosedDoors);


if (choreDoor === 0) {
  openDoor1 = botDoorPath;
  openDoor2 = beachDoorPath;
  openDoor3 = spaceDoorPath;
   } else if (choreDoor === 1) {
openDoor1 = beachDoorPath; 
openDoor2 = botDoorPath;
 openDoor3 = paceDoorPath;
  } else { (choreDoor === 2)   
openDoor1 = beachDoorPath;
 openDoor2 = botDoorPath;
  openDoor3 = spaceDoorPath;
  }



door1.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 = () => {
  if (!currentlyPlaying === false) {
    startRound();
  }
}


// Start a game round

const startRound = () => {
if (status === 'win') 
door1.src="closedDoorPath";
door2.src="closedDoorPath";
door3.src="closedDoorPath";

}
numClosedDoors.innerHMTL = 3;
currentlyPlaying .innerHMTL = true;
startButton.innerHMTL = 'Good Luck!';
randomChoreDoorGenerator();

startRound();

Check your curly braces { } - are they all present and accounted for?

That’s your most immediate error, but there are others (typos, for example) which I’m sure you’ll be able to resolve. :slight_smile:

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.