Review Algorithmic Thinking by Building a Dice Game - Step 14

Tell us what’s happening:

Can you guys help to find the problem?

Your code so far

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

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

const checkForStraights = (arr) => {
  const sorted = arr.sort((a,b) => a - b);
  const diceNum = Number(sorted.join(""));  
  
  if(diceNum === 12345 || diceNum === 23456) {
    updateRadioOption(4, 40);
    updateRadioOption(3, 30);
  }
  if (diceNum === 1234 || diceNum === 2345 || diceNum === 3456) {
    updateRadioOption(3, 30);
  }
  updateRadioOption(5, 0)
  console.log(diceNum)
}

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

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 14

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

Hi @shokhruzlevo

Console log the diceNum array, to see what it contains.

Happy coding

I did, I am seeing numbers, everything is okay with them

Even me I kinda dont understand, I did everything correct, diceNum is giving expected number. But this is what freeCodeCamp is sayin: If a small straight is rolled, your

checkForStraights

function should enable the fourth radio button, set the value to

30

, and update the displayed text to

, score = 30

.

have you tried to see what your function does with small straights? for example, checkForStraights([6,4,3,2,1])

what’s the value of diceNum?

what about checkForStraights([3,4,3,2,1])?

12346 and 12334 these are the results

look at your code, would it catch those straights?