Review Algorithmic Thinking by Building a Dice Game - Step 10

Tell us what’s happening:

It keeps saying that when my keepScoreBtn is clicked it should update the score in the totalScoreElement, but I think it already should? Since I called for updateScore(value, id). and I didn’t change anything to the updateScore() function. Could someone help me please?

Your code so far

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

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

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

  scoreHistory.innerHTML += `<li>${achieved} : ${selectedValue}</li>`;
};

keepScoreBtn.addEventListener("click", () => {
  checkedValue = undefined;
  scoreInputs.forEach((input) => {
    if (input.checked) {
      checkedValue = input;
    }
  })
  if (checkedValue === undefined) {
    alert("Please select an option.")
  } else {
    const {value, id} = checkedValue;
    updateScore(value, id);
    resetRadioOptions();
  }

})

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

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 10

Open the console and read the error.

  • Don’t re-declare updateScore

  • Make sure you do declare the checkedValue variable.

Thank you so much, spent one and a half hour finding the error and it turns out to be I forgot to variable keyword let infront of checkedValue. Thanks a lot.