Tell us what’s happening:
I am really close to solving this step I just can’t figure out how to check the actual value of the keys and check it in the if statement to get the correct outcome.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (arr) => {
const counts = {};
let total = 0;
diceValuesArr.forEach(ele => {
if (counts[ele]) {
counts[ele] += 1;
total += ele
} else {
counts[ele] = 1;
total += ele
}
})
console.log(counts)
console.log(Object.values(counts))
if (Object.values(counts) >= 4) {
updateRadioOption(0, total);
console.log("fourofakind")
} else if (Object.values(counts) === 3) {
updateRadioOption(1, total);
console.log("threeofakind")
} else {
updateRadioOption(5, 0);
console.log("none")
}
}
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
rollDice();
updateStats();
getHighestDuplicates();
}
});
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7