ChoreDoor

Hi, I am doing the Chore Door project and I have just completed step 62. When I save my code and find a chore bot on the first or second click, the Good Luck button (the big orange button on the bottom) is not saying “Game Over! Play again?”, instead it still says good luck. I have gone over my code and I dont know what is worng. Can someone help?

here is my code so far:

let doorImage1 = 
    document.getElementById('door1');

doorImage1.onclick = () => {
  if(!isClicked(doorImage1)) {
  doorImage1.src = openDoor1;
  playDoor(doorImage1)
}
}

let doorImage2 = 
    document.getElementById('door2');

doorImage2.onclick = () => {
 if(!isClicked(doorImage2)) {
  doorImage2.src = openDoor2;
  playDoor(doorImage2)
}
}

let doorImage3 = 
    document.getElementById('door3');

doorImage3.onclick = () => {
  if(!isClicked(doorImage3)) {
  doorImage3.src = openDoor3;
  playDoor(doorImage3)
}
}

const gameOver = (status) => {
  if (status === 'win') {
     startButton.innerHTML = 'You win! Play again?';
  } else {
    startButton.innerHtml = 'Game Over! Play again?'
  }
}

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

const botDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/robot.svg"

const beachDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/beach.svg"

const spaceDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/space.svg"

let closedDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/closed_door.svg";

let numClosedDoors = 3;

let openDoor1;
let openDoor2;
let openDoor3;

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= () => {
  numClosedDoors--;
  if (numClosedDoors === 0){
    gameOver('win');
  } else if (isBot(door)) {
 gameOver();
} 
}

const randomChoreDoorGenerator = () => {
var numClosedDoors = 3;
var 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;
}
}

randomChoreDoorGenerator()

Hello @codemaster08544! Welcome to the forum. These two functions have one problem each.

Look at the comments I added to your code. Examine these calls to the playDoor function:

playDoor(doorImage1)
playDoor(doorImage2)
playDoor(doorImage3)

You are passing an argument to the function, but the function doesn’t have a parameter to receive the argument passed.

Man, can’t believe I missed those. Thank You for your help! I will let you know if it works after i fix these problems.