Review Algorithmic Thinking by Building a Dice Game - Step 13

Tell us what’s happening:

my code is doing what it is suppose to? I’m new to coding and i know there’s probably a simpler way to approach this question, but as messy as it is, it still does what it’s suppose to do…please help

Your code so far

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

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

const detectFullHouse=(arr)=>{
  let one=0;
  let two=0;
  let three=0;
  let four=0;
  let five=0;
  let six=0;
  arr.forEach((num)=>{
    if(num===1){
      one++
    }
    if(num===2){
      two++
    }
    if(num===3){
      three++
    }
    if(num===4){
      four++
    }
    if(num===5){
      five++
    }
    if(num===6){
      six++
    }

  })
  const countArray=[one,two,three,four,five,six];
  for(let i=0;i<countArray.length;i++){
    for(let j=i+1;j<countArray.length;j++){
      if(countArray[i]===2&&countArray[j]===3){
        updateRadioOption(2,25)




      }
    }
  }




}


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 === 10000) {
    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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 13

Hello,
Can you please explain more what your issue is? I could not understand it

Hi @callmeeby253

I’m not sure what you are trying to do.
Can you briefly explain in your own words what the function does?

There are five dice, however the countArray contains six items.

Happy coding

the goal of this step was to create a function that detects a fullhouse, then changes the radio option and score span accordingly…when i roll a full house, the function does everything it’s expected to… so i’m just confused why it isn’t being accepted

the count array is keeping track of how many times a 1,2,3,4,5,6 occurs in the dicevalues arr… i know its messy code. im sorry i’m trying my best to get the hang of it

Hi @callmeeby253

The detectFullHouse function is not correctly syntaxed. It looks like there are extra closing curly braces. Have a look in the console to see the errors.

Happy coding