Hi All
I have just completed the Chore Door and I was just reviewing the code to makesure I understood it and the only thing I am confused about is why the playdoor function needs the door parameter as the door parameter is not referenced in the function block.
/* EACH TIME DOOR PLAYED DECREASE NUMBER OF AVALIABLE DOORS DOWN. REACH 0 YOU WIN, IF REACH BOT BEFORE ZERO LOSE */
const playDoor = (door) => {
numClosedDoors--;
if (numClosedDoors === 0) {
gameOver("win");
} else if (isBot(door) === true) {
return gameOver();
}
};
Is it because we include a parameter in playdoor function within the onclick functions?
// CHANGE IMAGE OF SOURCE ONCE CLICKED IF NOT ALREADY CLICKED BEFORE AND PLAYING THE GAME
doorImage1.onclick = () => {
if (!isClicked(doorImage1) && currentPlaying) {
doorImage1.src = openDoor1;
playDoor(doorImage1);
}
};
doorImage2.onclick = () => {
if (!isClicked(doorImage2) && currentPlaying) {
doorImage2.src = openDoor2;
playDoor(doorImage2);
}
};
doorImage3.onclick = () => {
if (!isClicked(doorImage3) && currentPlaying) {
doorImage3.src = openDoor3;
playDoor(doorImage3);
}
};
Thanks