Review Algorithmic Thinking by Building a Dice Game - Step 13

Tell us what’s happening:

The error says that ‘you should have a detectFullHouse function’. I have clearly defined the function. I am not sure how to address this error.

Your code so far

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

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

const detectFullHouse = (array) => {
  
  const counts = [];
  for(int i=0; i<array.length; i++) {
    let count = 1;
    if(isNaN(counts[i])) {
      for(int j=i+1; j<array.length; j++) {
        if(array[j] === array[i]) {
          count++;
        }
      }
      counts[i] = count;
      for(int j=i+1; j<array.length; j++) {
        if(array[j] === array[i]) {
          counts[j] = count;
        }
      }
    }
  }
  let twos = 0;
  let threes = 0;
  for(int i=0; i<counts.length; i++) {
    if(counts[i]===2) {
      twos++;
    }
    if(counts[i]===3) {
      threes++;
    }
  }
  if(twos === 2 && threes === 3) {
    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 (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

Welcome to the forum @elementarycoder1

You did not correctly structure the loop initialisation variables.

Happy coding