I have written the code for Step 7 of this exercise, however, I’m still getting 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.
Can anyone see the issue? I thought the code
if (highestCount >= 3) {
updateRadioOption(0, sumOfAllDice);
}
updates the radio option? But the code is not passing for some reason. I have the full code below for reference.
const getHighestDuplicates = (arr) => {
const counts = {}
for (const num in arr){
if (counts[num]){
counts[num]++
} else {
counts[num] = 1
}
}
let highestCount = 0
for (const num in arr){
const count = counts[num]
if(count >=3 && count > highestCount){
highestCount = count
}
if(count >=4 && count > highestCount){
highestCount = count
}
}
const sumOfAllDice = diceValuesArr.reduce((a, b) => a + b, 0);
if (highestCount >= 4) {
updateRadioOption(1, sumOfAllDice);
}
if (highestCount >= 3) {
updateRadioOption(0, sumOfAllDice);
}
updateRadioOption(5, 0);
}