Review Algorithmic Thinking by Building a Dice Game - Step 10

Tell us what’s happening:

Please help. My code works but I get no pass on check.

Your code so far

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

/* file: styles.css */

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

keepScoreBtn.addEventListener("click", () => {
  scoreInputs.forEach((input) => {
    if(!input.disabled){
      resetRadioOptions();
      updateScore(input.value, input.id);
      rolls = 0;
      round++; 
    }
  })
  
  })

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

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 10

Hi @Al3377 :wave:

It looks like you are not checking whether the input is checked on not.
For each of the inputs ( scoreInputs.foreach((input) . . . ) you are checking whether they are not disabled. You’re calling updateScore passing the input.value for the argument selectedValue, whether they’re checked or not:

It’s taking every input and adding up…

const updateScore = (selectedValue, achieved) => {
  score += parseInt(selectedValue);

The code might be working if you are getting a false-positive.

What I mean is, if you only have 1 option to choose from and you check it, then it will also be the only option that is also not disabled. So, it will appear to work, but not for the right reasons.

Try a scenario where you have more than 1 enabled radio button and you choose one.

Trying your code, I rolled until I got a three-of-a-kind, then I selected “none of the above” and it still added my 3-of-a-kind to my total. This means that any available options whether checked or not are going to be added to your total.

Beware the false positives! They’re a real pain.
Hope that helps.

1 Like

Ok thanks. Now I see what is the problem.

1 Like