Isn’t debugging fun?
I copied your code and I wasn’t getting an error in line 66 like you mentioned, but I did notice the doors were disappearing when clicked. So I followed the bread crumbs there.
onclick handlers are doing this:
doorImage1.src = openDoor1;
So that must be failing if the images are broken. And were are
openDoor3 defined? In your
randomChoreDoorGenerator function. That function looks ok, so I placed a
console.log there to see if it was being called. It wasn’t.
Who is calling
randomChoreDoorGenerator? Here is where we find the problem. You placed the call inside the
onclick handler for the start button. That’s not where we want it because we are assuming the user can play before clicking the button. You want to trigger this inside your
startRound function. Does that make sense?
The way your code is right now, you only generate what’s behind the doors when
startButton.onclick is triggered, and even then, your
randomChoreDoorGenerator is inside the
if statement that checks if you are currently playing (which, by default we set to
true at first). So that
if won’t do anything at first because
!currentlyPlaying will be false, your
randomChoreDoorGenerator then never gets called, and when you click a door there’s nothing to do the openDoor assignments.
Phew… little bug huh? Sometimes you have to pull the thread all the way to find the bug. Like I said, move your
randomChoreDoorGenerator out of
startButton.onclick and place it at the end of your