Tell us what’s happening:
It’s 2 days I’m trying this, even with the help of google, the fcc forum and the AI. I don’t know how to pass the level.
Trying the game, it works as expected if I comment updateScore() inside the function, otherwise, NaN appears. Please help.
Your code so far
/* file: script.js */
// User Editable Region
keepScoreBtn.addEventListener("click", () => {
let selectedOption = null;
for (let i = 0; i < scoreInputs.length; i++) {
if (scoreInputs[i].checked) {
selectedOption = scoreInputs[i].value;
break;
}
}
if (selectedOption === null) {
alert('Please select an option or roll the dice');
return;
}
//updateScore();
resetRadioOptions();
totalScoreElement.textContent = parseInt(totalScoreElement.textContent || 0) + parseInt(selectedOption);
scoreHistory.innerHTML += ` ${selectedOption}, `;
console.log(totalScoreElement.textContent);
console.log(scoreHistory.innerHTML);
console.log(selectedOption);
});
// 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/109.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 10