Review Algorithmic Thinking by Building a Dice Game - Step 14

Tell us what’s happening:

Is like there is a bug in this question how can i have two large straight one should be (3,30) and the other should be (4,40)? How is that possible?

Your code so far

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

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

const checkForStraights= (diceArr)=>{
const smallStraights = [
    [1, 2, 3, 4],
    [2, 3, 4, 5],
    ];

  const largeStraights = [
    [1, 2, 3, 4, 5],
    [2, 3, 4, 5, 6]
  ];

  // Helper function to check if a straight exists in dice rolls
  function containsStraight(rolled, straight) {
    return straight.every(value => rolled.includes(value));
  }

  // Check for large straight
  for (const large of largeStraights) {
    if (containsStraight(diceArr, large)) {
      updateRadioOption(4, 40);  // Large straight found
      return;
    }
  }

  // Check for small straight
  for (const small of smallStraights) {
    if (containsStraight(diceArr, small)) {
      updateRadioOption(3, 30);  // Small straight found
      return;
    }
  }

  // No straight found, update with 0 points
  updateRadioOption(5, 0);
 

}

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);
    checkForStraights(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/128.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 14

I’m not sure exactly what you are trying to say?

A large straight by definition includes a small straight.