Tell us what’s happening:
So here’s what I know I need to have.
The ability to count the numbers in the diceValuesArr. I have that.
The ability to tell the computer what each index is (I have one of those although it is not working)
Lastly, label the disable as false so it will be highlighted. I have not started the score stuff.
I am on day 2 of this lol.
Am I on the right track?
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const updateRadioOption = (index, score) => {
diceValuesArr = [1,2,2,2,5];
const counts = {};
diceValuesArr.forEach(el => {
counts[el] = (counts[el] | 0) + 1;
})
scoreInputs[index] = {
index: 0,
output: counts[diceValuesArr[index]] === 3
}
if (scoreInputs[index] === true) {
scoreInputs[index].disabled = false;
}
}
console.log(updateRadioOption())
// User Editable Region
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 6
Try to focus only what is asked in Step 6. Break it down into specific tasks:
Start by creating a function called updateRadioOption
that takes an index and a score value as arguments. It should set the scoreInputs
at that index to be enabled, set the value of that input to the score, and display , score = ${score}
in the correct scoreSpans
element.
Break it down:
- Start by creating a function called
updateRadioOption
that takes an index and a score value as arguments. 
- Set the
scoreInputs
at that index to be enabled
- set the value of that input to the score
- display
, score = ${score}
in the correct scoreSpans
element
Looking at the first line in your function:
diceValuesArr = [1,2,2,2,5];
I don’t see any mention of diceValuesArr
in the instructions?
Focus on step #2:
- Set the
scoreInputs
at that index to be enabled
Just do that and nothing else, it should be 1 line of code. Then move on to step 3.
I had the diceValuesArr set specifically so I could see if it works. I’ll take it out.
Take out everything that isn’t mentioned specifically in the instructions
I did the steps you suggested and it worked. I think this whole time I was just overthinking the instructions given. I appreciate you!
1 Like
Exactly, I think so as well. Just need to focus on exactly what the instructions ask for.
Good to be aware of the bigger picture of the program you are writing but the tests for each step are just going to be checking for exactly what’s in the instructions.
1 Like