Hello, my code seem to work, but challenge keeps giving out error:
When your keepScoreBtn is clicked, the score history should be updated.
Score history is updated in updateScore function, and everything seem to display correctly, so i’ve no idea what else i need to add
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
keepScoreBtn.addEventListener("click", () => {
const opt = ["Three of a kind","Four of a kind","Full house","Small straight","Large straight","None"];
const chk = [];
for (let i = 0; i < opt.length; i++) {
chk.push(scoreInputs[i].checked);
if (scoreInputs[i].checked) {
updateScore(scoreInputs[i].value, opt[i]);
resetRadioOptions();
return;
}
if (i === 5 && !chk.some(ele => ele)) {
alert("Choose something...");
};
};
});
// 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/126.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 10
I am not sure if you have followed the instructions in full. For eg. You were supposed to capture the id of the checked option and use it to update the score history?
I did what i could, and the resulting code seem to do what challenge is asking. If it’s wrong then i need help, since i’ve no idea how to do it correctly.
I actually have not tried this project yet so I am not sure if I can state an opinion on its user interface design. I think for the purpose of teaching, it works either way though?
Can I make one suggestion?
Instead of how you currently determine if any option is checked, have you considered just initializing a boolean variable to false and then when you see any checked option, setting the boolean variable to true? That way when you need to know if the user made a selection, you can just check the boolean variable as a truthy? (It would be simpler logic maybe?)
Also you could put the final check outside the loop so that you don’t have to check if i === 5