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