Chore Door start button isn't working


#1

I’ve completed the chore door project and everything is working minus my start button. Any help in the right direction would be greatly appreciated!

Chore Door Project Link

Here is my code on codepen:


#2
const startRound = () =>{
    var doorImage1 = document.getElementById('door1');
    var doorImage2 = document.getElementById('door2');
    var doorImage3 = document.getElementById('door3');
    var startButton = document.getElementById('start');
  let currentlyPlaying = true;
    let numClosedDoors = 3;
  randomChoreDoorGenerator();
}

These lines do not need to be repeated.

    var doorImage1 = document.getElementById('door1');
    var doorImage2 = document.getElementById('door2');
    var doorImage3 = document.getElementById('door3');
    var startButton = document.getElementById('start');

since they are already cached.

Organize your code so that it takes on this approximate order…

  1. Cache element nodes (a one time action).
  2. Initiallize global variables (only need to be declared, not defined)
  3. Write all the functions in a sensible order (calls to the functions should be below where they are written).
  4. Group all listeners at the bottom.

By removing those var lines from startRound you won’t be wiping out the listeners. Don’t use var or let inside this function. It will end up shadowing the global variables.


#3

Did you solve this?
I’ve checked your codepen and it seems to be working


#4

If you are referring to the above pen, the doors are not getting randomized, it seems.


#5

Somewhat correct, they will be random, but only if you click on a different door to start. So one problem solved, but a new one created.


#6

Please paste your revised code here so we can take a look at it.