Review Algorithmic Thinking by Building a Dice Game - Step 12

Tell us what’s happening:

Please help me get through this, why its still say that call your resetGame function after displaying the alert in your keepScoreBtn listener, thanks

Your code so far

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

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

const resetGame = () => {
  listOfAllDice.forEach(die => die.textContent = `0`);
  score = 0;
  round = 1;
  rolls = 0;
  
  totalScoreElement.textContent = score;
  scoreHistory.innerHTML = "";
totalScoreElement.textContent = score;
  rollsElement.textContent = rolls;
  roundElement.textContent = round;
}


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/129.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 12

Move the call so it just after the alert

i tried but it didnt work :frowning:

You may have other things to fix in your reset game function.
For eg. You should be calling the function to reset the radio options instead of doing the reset manually.

I was also facing the same issue Use the setTimeout on reset button also that would work for you as well.

Huh? This sentence makes no sense?

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.