Tell us what’s happening:
Grand Rising to everyone;
I am having some problem setting up this code to meet up with the requirements in the task. I have used the forEach() and the current for…in loop to complete the task , but I keep ending up with the same message as shown below:
When the array has three of the same number, your getHighestDuplicates function should update the Three of a Kind radio option with , score = and the total sum of the dice.
I have spend some hours figuring this out on my own but at this point, I find it connivence to seek external help. Can someone please me point out the fault in the blocks of code below. Your kind gestures will be much appreciated.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (array) => {
let counts = [];
let fourOfAKind = "disabled";
let threeOfAKind = "disabled";
for (const dice in array) {
if (counts[dice]) {
counts[dice]++;
} else {
counts[dice];
}
}
let identicalNum = 0;
for (const dice in array) {
const getCount = counts[dice];
if(getCount >= 4 && getCount > identicalNum) {
identicalNum = getCount;
} else if(getCount >= 3 && getCount > identicalNum) {
identicalNum = getCount;
}
}
const sumAllDice = array.reduce((ax, az) => az + az, 0);
if (identicalNum >= 4) {
fourOfAKind = "enabled";
updateRadioOption(1, sumAllDice);
} else if (identicalNum >= 3) {
threeOfAKind = "enabled";
updateRadioOption(0, sumAllDice);
} else {
fourOfAKind;
threeOfAKind;
updateRadioOption(5, 0);
}
};
// 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/129.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7