Chore Door - doors not opening after function

Hello, i need help with this project. It was easy until i had to create the function for the random number. The doors worked before, but after i created the function between step 40 and step 45, the doors are locked.
here’s my code

<!DOCTYPE html>
    <title>Chore Door!</title>
    <link href="./style.css" rel="stylesheet" type="text/css">
    <link href="" rel="stylesheet" type="text/css">

    <div class="header">
      <img src="">
      <div class="title-row">
        <img src = "">
        <p class="instructions-title">Instructions</p>
        <img src = "">

      <table class="instructions-row">
          <td class="instructions-number">1</td>
          <td class="instructions-text">Hiding behind one of these doors is the ChoreBot.</td>
          <td class="instructions-number">2</td>
          <td class="instructions-text">Your mission is to open all of the doors without running into the ChoreBot.</td>
          <td class="instructions-number">3</td>
          <td class="instructions-text">If you manage to avoid the ChoreBot until you open the very last door, you win!</td>
          <td class="instructions-number">4</td>
          <td class="instructions-text">See if you can score a winning streak!</td>

      <div class='door-row'>
        <img id="door1" class="door-frame" src="">
        <img id="door2" class="door-frame" src=""> 
        <img id="door3" class="door-frame" src=""> 
 <div id="start" class="start-row">
   Good Luck!
 <script type="text/javascript" src="script.js"></script>



body {
  background-color: #010165;
  margin: 0px;

.header {
  text-align: center;

.title-row {
  margin-top: 42px;
  margin-bottom: 21px;
  text-align: center;

.instructions-title {
  display: inline;
  font-size: 18px;
color: #00ffff;
font-family: ‘Work Sans’;

.instructions-row {
  margin: 0 auto;
  width: 400px;


.instructions-number {
  font-family: ‘Work Sans’;
  font-size: 36px;
  color: #00ffff;

.instructions-text {
  padding: 10px;
  font-family: ‘Work Sans’;
  font-size: 14px;
  color: #ffffff;

  text-align: center;

.door-frame {cursor:pointer;
padding: 10px;

.start-row {
  margin: auto;
width: 120px;
height: 43px;
font-family: ‘Work Sans’;
background-color: #eb6536;
padding-top: 18px;
font-size: 18px;
text-align: center;
color: #010165;
cursor: pointer;


let beachDoorPath ="";
let spaceDoorPath= "";
let botDoorPath = '';

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

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

doorImage1.onclick = () => {doorImage1.src=openDoor1};

doorImage2.onclick = () => {doorImage2.src=openDoor2};

doorImage3.onclick = () => { doorImage3.src=openDoor3};

let randomChoreDoorGenerator= () => { let choreDoor = Math.floor(Math.random() * numClosedDoors);
  if(choreDoor === 0){
    openDoor1= botDoorPath;
else if(choreDoor===1){openDoor2= botDoorPath;
else{(choreDoor===2) openDoor3= botDoorPath;openDoor2=beachDoorPath;



Are you sure that your last else should look like this? Or even be an else?


no :smiley: it should be else if or just else without (choreDoor===2), but i just followed the tutorial step by step and in her video it works

minute 44:18

You’re free not to follow the tutorial to the letter :wink:

Why not experiment with the code? Trying different things, see what works, what doesn’t?

I see a lot of copy/pasting in this tutorial anyway. You might want to try it by yourself?

Modifying that line should work.

1 Like

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