Review Algorithmic Thinking by Building a Dice Game - Step 12

Tell us what’s happening:

const listOfAllDice = document.querySelectorAll(“.die”);
const scoreInputs = document.querySelectorAll(“#score-options input”);
const scoreSpans = document.querySelectorAll(“#score-options span”);
const roundElement = document.getElementById(“current-round”);
const rollsElement = document.getElementById(“current-round-rolls”);
const totalScoreElement = document.getElementById(“total-score”);
const scoreHistory = document.getElementById(“score-history”);
const rollDiceBtn = document.getElementByI

Your code so far

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

/* file: styles.css */

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

round = 6

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

  resetRadioOption()
}

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

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 @joseito

Check the names of the variables and the function name.

Happy coding