Review Algorithmic Thinking by Building a Dice Game - Step 10

Tell us what’s happening:

My code seems to work correctly but when I’m trying to Submit the exercise I get this error: When your keepScoreBtn is clicked, the score should be updated in the totalScore text.
When your keepScoreBtn is clicked, the score history should be updated.
I tried to move the updateScore() function inside the if statement if(selectedValue){} but it does the same think. The same error.
The Total score is updating when I press the keepScoreBtn so I don’t understand what is wrong

Your code so far

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

/* file: styles.css */

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

keepScoreBtn.addEventListener("click", ()=>{
  let selectedValue;
  let achieved;

  for (const radioButton of scoreInputs){
    if(!radioButton.disabled){
      achieved = radioButton.id;
      selectedValue = radioButton.value;
      break;
    }
  }
   if (selectedValue){
   rolls = 0;
   round++;
    updateStats();
   } else{
     alert("Select an Option");
   }

  updateScore(selectedValue, achieved)
  resetRadioOptions()

  console.log(selectedValue, achieved);
})

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

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 10

You need to get the choice that the user has checked.

if you try to roll the dice and click on the keepScoreBtn without selecting anything, you will see that the first option that is not disabled will be counted for you even though you didn’t select it.


This will get the first not disabled choice, but you need to get the choice that the user has checked.

1 Like

I think after alert you should exit the function immediately?

Thanks a lot. That was the problem