Review Algorithmic Thinking by Building a Dice Game - Step 9

Tell us what’s happening:

My code passes successfully, but I don’t understand why. If “selectedValue” refers to the value of the radio button, according to the HTML that should be the “value” that we see below:

<input type="radio" name="score-options" id="three-of-a-kind" value="three-of-a-kind" disabled />

But in this case, that “value” is the string “three-of-a-kind”. How is it possible that a string of purely text is being successfully parsed as an integer?

Your code so far

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

/* file: styles.css */

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

const updateScore = (selectedValue, achieved) => {
  score += parseInt(selectedValue);
  totalScoreElement.textContent = score;
  scoreHistory.innerHTML += `<li>${achieved} : ${selectedValue}</li>`;
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 9

Further information: the instructions for this step are as follows:

“Create an updateScore function to add this functionality. Your function will need two parameters for the user selected score option. The first parameter will be passed the value of the radio button, remember this is a string, and the second parameter will be passed the id value of the radio button, which is the type of score they achieved.”

As you can see, they specifically say that the first parameter will be passed the value of the radio button, which – according to the HTML – is always a string that contains no digits.

you also need to consider the updateRadioOption function, it has scoreInputs[index].value = score where score is a number