Review Algorithmic Thinking by Building a Dice Game - Step 13

Tell us what’s happening:

Earlier this code was working I am not sure what went wrong. Can someone please let know what is the issue here. Thank you for taking the time.

Your code so far

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

/* file: styles.css */

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

const detectFullHouse = (arr) => {
    let objValue = {};
    for(el of arr){
      if(objValue[el]){
        objValue[el] += 1;
      }else{
        objValue[el] = 1;
      }
    }    
    console.log(objValue);

    const checkArr = [...Object.values(objValue)];
    if(checkArr.includes((2 && 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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 13

Hi there!

The issue is that, that el is not defined. You need to add declaration keyword. @fortechaditya

Thank you so much I don’t know why VS code didn’t show any error to this. Could you help me understand that as well why that might have been the case ? Also thank you for taking the time to reply back.

VS Code might not have caught the error because it doesn’t always flag undeclared variables within a loop unless strict linting is enabled. To ensure VS Code catches these kinds of issues, consider using the “ESLint” extension, which can alert you to undeclared variables and other potential problems in real-time. You could also enable “strict mode” in JavaScript by adding “use strict”; at the beginning of your file, which helps catch such errors early.