Tell us what’s happening:
I checked countOfDupes
in a separate JSFiddle, and that performs what I want: it eventually becomes a number that counts the mode. I did it differently from that one tutorial from this site about stats. Is that an issue here?
I don’t understand the logic in the next step, either. It looks like I do something if there are four of a kind, three of a kind, or nothing. But what? I used updateRadioOption()
, which requires an index and a score. Do I understand how to score correctly?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (arrayOfNumbers) => {
let countOfDupes = [];
const sum = arrayOfNumbers.reduce((acc, init) => acc + init, 0);
for (let i=0; i < arrayOfNumbers.length; i++) {
countOfDupes.push(
arrayOfNumbers.filter(
element => element === arrayOfNumbers[i]));
}
countOfDupes = countOfDupes.map(element => element.length);
console.log("Count of Dupes Array: ",countOfDupes);
countOfDupes = Math.max.apply(null, countOfDupes);
console.log("Count of Dupes as a number: ", countOfDupes);
if (countOfDupes >= 4) {
updateRadioOption(1, sum);
} else if (countOfDupes === 3) {
updateRadioOption(0, sum);
} else {
updateRadioOption(-1, 0);
}
}
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
rollDice();
updateStats();
}
});
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7