Review Algorithmic Thinking by Building a Dice Game - Step 2

Tell us what’s happening:

I do not understand where my error is, the code works. The rules container is visible and invisible when I press the button. Yet I am still getting the rulesBtn is clicked, your rulesContainer should be visible. Finally I keep getting the error of rules Container should not be visible initially.

I did at one point not have the rulesBtn is clicked error in the console, yet my code I’m pretty sure was the exact same as it is now. Could be wrong though, I tried both display and visibility. Same error for both.

Your code so far

<!-- file: index.html -->

/* file: script.js */
// User Editable Region

rulesBtn.addEventListener("click", () => {
  isModalShowing = !isModalShowing;

  rulesContainer.style.display = isModalShowing ? "block" : "none";

  rulesBtn.textContent = isModalShowing ? "Hide rules" : "Show rules";

});

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1.2 Safari/605.1.15

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 2

I actually just tried your code and it passes for me. Maybe reset and retry?

Yeh I have tried to reset multiple times. It just gives me the same errors and/or more errors. However, the code seems to work?

the code works and it passes for me when I copy exactly this:

not sure if it going to allow me to show the screenshot, I copied that exactly and it still gives me the same errors.

not sure if it will help, but try a different browser or try incognito mode in case something else is going on.

Thank you, switched browser and that somehow worked.

1 Like

This challenge seems to expect a simple toggle inverter for the variables mentioned.