Review Algorithmic Thinking by Building a Dice Game - Step 12

Tell us what’s happening:

I have moved my resetGame() function to all different places but I keep getting the error You should call you resetGame function after displaying the alert in your keepScoreBtn listener. I have reset, I have refreshed and it won’t pass!!! I have put it on the same line. I have put it directly after the `) why won’t it pass? I need specifics because I have put it everywhere that I found in the forum. I am so frustrated

Your code so far

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

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

const resetGame = () => {
  listOfAllDice.forEach(die => die.textContent = `0`);
  score = 0;
  rolls = 0;
  round = 1;

  totalScoreElement.textContent = score;
  scoreHistory.textContent = "";
  rollsElement.textContent = rolls;
  roundElement.textContent = round;
  alert(`Final score: ${score}`);
  resetRadioOptions();
};
rollDiceBtn.addEventListener("click", () => {
  if (rolls === 3) {
    alert("You have made three rolls this round. Please select a score.");
  } else {
    rolls++;
    resetRadioOptions();
    rollDice();
    updateStats();
    getHighestDuplicates(diceValuesArr);
  }
});

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

  if (isModalShowing) {
    rulesBtn.textContent = "Hide rules";
    rulesContainer.style.display = "block";
  } else {
    rulesBtn.textContent = "Show rules";
    rulesContainer.style.display = "none";
  }
});

keepScoreBtn.addEventListener("click", () => {
  let selectedValue;
  let achieved;

  for (const radioButton of scoreInputs) {
    if (radioButton.checked) {
      selectedValue = radioButton.value;
      achieved = radioButton.id;
      break;
    }
  }

  if (selectedValue) {
    rolls = 0;
    round++;
    updateStats();
    resetRadioOptions();
    updateScore(selectedValue, achieved);
  if (round > 6) {setTimeout(() => {alert(`Game Over! Your total score is ${score}`)  },500); resetGame ;
     } 
  } else {
    alert("Please select an option or roll the dice");
  }
});

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 12

I realize the () weren’t after the resetGame function I corrected that and still got the exact same error message

Hi @julieperk

Here is a comparison of the original code and your code.

The code in blue is the original code, the code in red is your code.
The code in magenta is the overlap.

It looks like you modified the code.

Please make a copy of the new function, then reset the step and try again.

Happy coding

I did that cause one person said to put it on same line.

That can make the code harder to ready.

Looks like there is an extra parentheses.

I reset the whole step and have this
if (round > 6) { setTimeout(() => { alert(Game Over! Your total score is ${score}); }, 500); resetGame()
I didn’t touch any of they code except adding resetGame and where is an extra parentheses?

Didn’t help I’m about to pull my hair out in frustration

I’m desperate at this point I’ll do whatever it takes to get this stupid thing to pass

Remove this line from the resetGame function.

Place the function call in the blank line below.

    if (round > 6) {
      setTimeout(() => {
        alert(`Game Over! Your total score is ${score}`);

      }, 500);
    }
  } else {

You didn’t place the call after the alert, it was after the time delay.
I think the blank line given in the seed code is misplaced.

thanks for the extra alert tip. that made all the difference. It finally passed.

1 Like