i have managed the checked attribute but now i dont understand about the value and id , and how to update score i totalscore element
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
// here is code for this current problem(below this comment)
keepScoreBtn.addEventListener("click",()=>{
/* checked,capture value and attribute
update score'
reset radio options
record in score history
*/
for(i = 0; i < scoreInputs.length; i++) {
const ele = scoreInputs;
if (ele[i].checked){
totalScoreElement.textContent =+ updateScore ();
resetRadioOptions();
scoreHistory.innerHTML += `<li>${value} : ${id}</li>`;
}
else{
alert
}
};
})
//alert();
// 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/138.0.0.0 Safari/537.36 Edg/138.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 10
this is my current code: for(i = 0; i < scoreInputs.length; i++) {
const input = scoreInputs[i].value;
if (input.disbled = false){
totalScoreElement.textContent = updateScore();
resetRadioOptions();
scoreHistory.innerHTML += `
${value} : ${id}
`};
the for loop goes through the radio options,then if clicked (disabled false) totalscore element updates toslscore the radiooptions is reset and score history uodated,i think
There is a div in the HTML with an id of score-options and inside that div, there are several radio buttons named score-options, but can you say how to determine which of those radio buttons has been checked?
Let’s get the checked radio button handled first before we move forward. You still have some work to do there. For example, look at the following line:
for(i = 0; i < scoreInputs.length; i++)
Look up an example of a for loop. You are missing something. What do we need to do with variables before we can use them?
Also, why do you need to create a variable ele?
When you’re ready, show your code through the if statement. Remove all the code you wrote after the if statement.
The syntax of your for loop is more incorrect now than it was when you first wrote it. Did you look up an example of the for loop syntax?
scoreInputs is what type of data construct? How can you determine a checked state for the data construct you have written? Remember, you are inside a loop here and you are trying to determine which, if any, radio button was checked. That is all you should be doing inside the loop.
Good that you are now passing in values for updateScore parameters, but where is value and id coming from? There are no variables in this block of code called value or id. And when we call a function there is no space between the function name and the parenthesis.
Good that you are now declaring i correctly in the loop, but your condition is trying to get the length of scoreInputs at index i. What do you really want your condition to be the length of?