Review Algorithmic Thinking by Building a Dice Game - Step 13

Tell us what’s happening:

I am very confused, my code works but I can’t get it to pass the step :frowning: Can someone help me out? I keep getting the error
"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"”

Your code so far

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

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

const detectFullHouse = (arr) => {
  const counts = {};
  Array.from(diceValuesArr).forEach(die => {
    let value = die;
    counts[value]=(counts[value] || 0) + 1;
  });
  let values = Object.values(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
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 13

you should be using the parameter given to the function and not the diceValuesArr

(also as the array is already an array, you don’t need the Array.from call)

This worked, thank you so much :smiley:

1 Like