Review Algorithmic Thinking by Building a Dice Game - Step 12

Tell us what’s happening:

I’ve done what the step calls for but the system is still telling me to set each “listOfAllDice element” to 0. What am I doing wrong?

Your code so far

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

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

const resetGame = () => {
  // Reset dice values array to all zeros
  diceValuesArr = [0, 0, 0, 0, 0];

  // Reset game state variables
  score = 0;
  rolls = 0;
  round = 1;

  // Reset the displayed text for all dice elements
  listOfAllDice.forEach((dice) => {
    dice.textContent = diceValuesArr;
  });
  listOfAllDice.forEach((index) => {
    dice.textContent = diceValuesArr[index];
  })  
  // Update the displayed total score
  totalScore.textContent = score;

  // Clear the score history
  scoreHistory.innerHTML = "";

  // Update the displayed number of rolls and current round
  currentRoundRolls.textContent = rolls;
  currentRound.textContent = round;

  // Call the function to reset radio options
  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}`);
      resetGame();
      }, 500);

    }
  } 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 12

Try logging the diceValuesArray in your code here. Is it what you thought it was?