Review Algorithmic Thinking by Building a Dice Game - Step 13

Tell us what’s happening:

const detectFullHouse = (arr) =>{
const counts = {};

for (const num of arr) {
if (counts[num]) {
counts[num]++;
} else {
counts[num] = 1;
}
}
const values=Object.value(counts);
if(values.includes(3) && values.includes(2)){
updateRadioOption(2, 25);

}
updateRadioOption(5, 0);
};

const resetRadioOptions = () => {
scoreInputs.forEach((input) => {
input.disabled = true;
input.checked = false;
});

scoreSpans.forEach((span) => {
span.textContent

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const detectFullHouse = (arr) =>{
  const counts = {};

  for (const num of arr) {
    if (counts[num]) {
      counts[num]++;
    } else {
      counts[num] = 1;
    }
  }
const values=Object.value(counts);
if(values.includes(3) && values.includes(2)){
   updateRadioOption(2, 25);

}
 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];
  });

  totalScoreElement.textContent = score;
  scoreHistory.innerHTML = "";

  rollsElement.textContent = rolls;
  roundElement.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(diceValuesArr)
  }
});

// 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/129.0.0.0 Safari/537.36 Edg/129.0.0.0

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 13

Hello!
What kind of issue are you having? Talk to us.

my code is not passing because Sorry, your code does not pass. Hang in there.

When a full house is rolled, your detectFullHouse function should enable the third radio button, set its value to 25, and set the third span to display the text , score = 25.

Always look at the console when you develop code in JavaScript. Your console is showing these errors:

// console output
[TypeError: Object.value is not a function. (In ‘Object.value(counts)’, ‘Object.value’ is undefined)]
[TypeError: Object.value is not a function. (In ‘Object.value(counts)’, ‘Object.value’ is undefined)]
TypeError: Object.value is not a function. (In ‘Object.value(counts)’, ‘Object.value’ is undefined)

1 Like