Tell us what’s happening:
My test is failing, despite my application working properly both when I manually set my object to a full house (see commented out line in the code), and after testing the program enough times to finally roll one. I’m suspecting this is because of how the test is set up, that I fail because I moved the declaration of my count object to the global space, and re-used the work from the getHighestDuplicates method. I would appreciate feedback on this approach, even though I will try re-doing steps to see if I can pass the test.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const detectFullHouse = () => {
//counts = {1: 1, 2: 1, 3: 3}
if(Object.keys(counts).length === 2 && Object.values(counts).includes(3)) {
updateRadioOption(2, 25);
} else {
updateRadioOption(5, 0);
}
}
const resetRadioOptions = () => {
scoreInputs.forEach((input) => {
input.disabled = true;
input.checked = false;
});
scoreSpans.forEach((span) => {
span.textContent = "";
});
};
const resetGame = () => {
diceValuesArr = [0, 0, 0, 0, 0];
score = 0;
round = 1;
rolls = 0;
listOfAllDice.forEach((dice, index) => {
dice.textContent = diceValuesArr[index];
});
totalScore.textContent = score;
scoreHistory.innerHTML = "";
currentRoundRolls.textContent = rolls;
currentRound.textContent = round;
resetRadioOptions();
};
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
resetRadioOptions();
rollDice();
updateStats();
getHighestDuplicates(diceValuesArr);
detectFullHouse();
}
});
// 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/127.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 13