Review Algorithmic Thinking by Building a Dice Game - Step 13

Tell us what’s happening:

I am getting the following 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.

even though I hav enabled the 3rd radio funtion with score 25

Your code so far

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

/* file: styles.css */

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

function detectFullHouse(arr){
  const f={};
  for(let i in arr){
    f[i] = (f[i] || 0) + 1;
  }
  let value=Object.values(f);
  if(value.includes(3) && value.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/135.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 13

Have you checked if it works? For testing you could modify the rollDice function, or call detectFullHouse below where it’s defined with array having full house, ie.:

detectFullHouse([1,1,2,2,2])

No, it’s not working for this.

Infact the console is showing another type of output.

like it is not working as counter.

I suggest console.log(i) inside the loop, so you see that

got it guys, i is for doing the index, had to use f[i] instead.