Review Algorithmic Thinking by Building a Dice Game - Step 10

Tell us what’s happening:

My code passes but I don’t understand why. The alert is only supposed to show when none of the radio options are selected. With the way my code is written, it looks like the alert, positioned outside the forEach loop, will display regardless after clicking. I wrote this as a placeholder while I try to figure out how to write ‘if (no option is selected).’

Your code so far

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

/* file: styles.css */

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

keepScoreBtn.addEventListener("click", () =>{
  scoreInputs.forEach(el => {
    if (el.checked){
      updateScore(el.value, el.id)
      resetRadioOptions()
    }
  }) 
  alert()
})

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 10

Shouldn’t something like this be required:
mod edit: code removed

Please do not share code here unless you are requesting help with it in your own post. The OP asked a question about why the code works a certain way and your response did not address that.

1 Like

It might be a bug in the checking code.