Review Algorithmic Thinking by Building a Dice Game - Step 14

Tell us what’s happening:

I don’t why it is not working. I tried all the other method that i could think of.

Your code so far

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

/* file: styles.css */

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

const checkForStraights = (arr) => {
  const sorted = [...new Set(arr)].sort((a, b) => a - b);

  const sortedStr = sorted.join("");

  if (sortedStr === "12345") {
    updateRadioOption(3, 30);
    updateRadioOption(4, 40);
  } 
  else if (sortedStr.includes("1234") || sortedStr.includes("2345")) {
    updateRadioOption(3, 30);
    scoreInputs[4].disabled = true;
  } 
  else {
    scoreInputs[3].disabled = true;
    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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 14

Do your hard-coded sortedStr values reflect all of the numbers on a die?

don’t do this, let updateRadioOption do things

also make sure that your function validate all possible large and small straights

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.