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. — this is my error although it works in the preview
const getHighestDuplicates = () => {
console.log(diceValuesArr);
let currentNum ;
let match;
score = 0;
let highestMatch = 0;
for (let x = 0; x < diceValuesArr.length; x++){
currentNum = diceValuesArr[x];
match = 0;
diceValuesArr.forEach((dice) => {
if (currentNum === dice){
match++;
}
if (match > highestMatch){
highestMatch = match;
}
});
}
console.log(highestMatch);
if (highestMatch >= 4) {
score = sum(diceValuesArr);
updateRadioOption(1, score);
console.log('x',highestMatch, currentNum, score);
} else if (highestMatch === 3){
score = sum(diceValuesArr);
updateRadioOption(0, score);
console.log('f',highestMatch, currentNum, score);
} else {
score = 0;
updateRadioOption(5, score);
}
};
```html
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
// User Editable Region
```css
/* 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/128.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7
now my error is this:
When the array has less than three of the same number, your getHighestDuplicates function should update the final radio option with , score = 0 .
on your reply: You need to update the last option every time the function is called (not as they said). – can you clarify please.
it gives me this warning: When the array has less than three of the same number, your getHighestDuplicates function should not update the first nor the second radio options.
i did. here is my console result:
[ 6, 6, 6, 5, 6 ]
4
x 4 6 29
it enabled 3 and 4 and 0 but i still have this warning:
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.
here is the error:
When the array has less than three of the same number, your getHighestDuplicates function should not update the first nor the second radio options.
0 is enabled and the error:
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.
still the same: 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.