Review Algorithmic Thinking by Building a Dice Game - Step 9

Tell us what’s happening:

const updateScore = (selectedValue, achieved) => {

if (isNaN(scoreValue)) {
console.error(“Invalid score value.”);
return;
}
score += selectedValue;
totalScoreElement.textContent = score;
scoreHistory.innerHTML = <li>${achieved} : ${selectedValue}</li>

}
please help

Your code so far

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

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


const updateScore = (selectedValue, achieved) => {
  
   if (isNaN(scoreValue)) {
        console.error("Invalid score value.");
        return;
    }
    score += selectedValue;
    totalScoreElement.textContent = score;
    scoreHistory.innerHTML = `<li>${achieved} : ${selectedValue}</li>`


}

// 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/129.0.0.0 Safari/537.36 Edg/129.0.0.0

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 9

you are not asked to add this, the tests do not expect it and it can give unexpected results from the tests


you need to convert to an integer before summing

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

still not right

There is no variable called totalScore? But there is one called score.

Thanks for helping
It has solved the issue

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.