Review Algorithmic Thinking by Building a Dice Game - Step 12

Tell us what’s happening:

it keeps telling me to call my resetGame function after displaying the alert in the keepScoreBtn listener which I have already done. I can’t seem to find the problem for some days now. any advice?

Your code so far

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

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


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


  scoreHistory.textContent = "";
  rollsElement.textContent = rolls;
  totalScoreElement.textContent = score;
  roundElement.textContent = round;
  scoreSpans.forEach(element => element.textContent = "")

  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) {
      alert(`Game Over! Your total score is ${score}`);
      resetGame(); 
    }
  } else {
    alert("Please select a score option before proceeding to the next round.");
  }
});

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

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 12

Hi there!

Remove the above line of code from the function resetGame. It’s not asked to add that line in the challenge instructions.

I have done that but it is still not running.

There was a setTimeOut function within the if block. You have removed that. Reset the challenge to restore the original code back and try again.

I have updated that too, thanks,
tested the app, and it is working fine. I am done with it. it just refused to submit this particular step.

Post your updated code here.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.