Review Algorithmic Thinking by Building a Dice Game - Step 14

Tell us what’s happening:

hey help me to solve this ASAP
Showing this error/issue
Your checkForStraights variable should be a function.

Your code so far

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

/* file: styles.css */

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

const checkForStraights = (arr) => {
  const sortedNumbersArr = arr.sort((a, b) => a - b);
  const uniqueNumbersArr = [...new Set(sortedNumbersArr)];
  const uniqueNumbersArr = uniqueNumbersArr.join("");

  const smallStraightsArr = ["1234", "2345", "3456"];
  const largeStraightsArr = ["12345", "23456"];

  smallStraightsArr.forEach((straight) => {
    if (uniqueNumbersArr.includes(straight)) {
      updateRadioOption(3, 30)
    }
  })

  if(largeStraightsArr.includes(uniqueNumbersArr)){
    updateRadioOption(4, 40)
  }

  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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 14

1 Like

I’m sorry your are experiencing a coding emergency that must be solved ASAP or else?

The console shows the following syntax error:

SyntaxError: unknown: Identifier 'uniqueNumbersArr' has already been declared. (137:8)

  135 |   const sortedNumbersArr = arr.sort((a, b) => a - b);
  136 |   const uniqueNumbersArr = [...new Set(sortedNumbersArr)];
> 137 |   const uniqueNumbersArr = uniqueNumbersArr.join("");
      |         ^
  138 |
  139 |   const smallStraightsArr = ["1234", "2345", "3456"];
  140 |   const largeStraightsArr = ["12345", "23456"];

so any solution if you have ,please suggest

Well, this says that uniqueNumebrsArr was already declared once, so I wouldn’t declare it twice.

1 Like

ohk thanks …I got it

1 Like

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