Tell us what’s happening:
keepScoreBtn.addEventListener(“click”, () => {
let selectedValue=“”;
let id;
for(let id of scoreInputs){
if(id.checked){
selectedValue = id.value;
id = checkedBtn.id
break;
}
}
if(selectedValue){
updateScore(selectedValue, id);
resetRadioOptions();
totalScoreElement.textContent=score;
scoreHistory.innerHTML += `<li>${id} : ${selectedValue}</li>`;
}
else{
alert("Select an Option");
}
}
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
keepScoreBtn.addEventListener("click", () => {
let selectedValue="";
let id;
for(let id of scoreInputs){
if(id.checked){
selectedValue = id.value;
id = checkedBtn.id
break;
}
}
if(selectedValue){
updateScore(selectedValue, id);
resetRadioOptions();
totalScoreElement.textContent=score;
scoreHistory.innerHTML += `<li>${id} : ${selectedValue}</li>`;
}
else{
alert("Select an Option");
}
}
// 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/126.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 10
In the console is [ReferenceError: scoreInputs is not defined].
Anyone have a idea ??
when you see an error like this you should look for the way the scoreInputs was declared. (if it was not declared in the scope of the line giving the error, then that is a problem)
const scoreInputs = document.querySelectorAll(“#score-options input”);
const keepScoreBtn = document.getElementById(“keep-score-btn”);
this 2 are given the error… they are correct?
this line is missing its matching parenthesis in the code you shared.
Not sure if this is the case also on your end?
After I copied the code and added the missing paren, I then see this error in the console:
Uncaught ReferenceError: checkedBtn is not defined
I don’t ever see the error you reported though.
You right this is the 2 ERROR
[ReferenceError: scoreInputs is not defined]
[ReferenceError: keepScoreBtn is not defined]
and I pass the declarations:
const scoreInputs = document.querySelectorAll(“#score-options input”);
const keepScoreBtn = document.getElementById(“keep-score-btn”);
I dont have anymore ideas to solve…
Try to reset the step, you may have changed something else by accident.
I do that … anda I remove the “break;” and improved now the ERROR is scoreHistory need to be update:
scoreHistory.innerHTML += <li>${id} : ${selectedValue}</li>
;
You should copy the code here so we can try it.
it is solved…
it was a break in the if
and the += in the scoreHistory.innerHTML need to be replace with “=”
1 Like