Review Algorithmic Thinking by Building a Dice Game - Step 14

Tell us what’s happening:

Please help, what am I doing wrong?

I don’t understand why it keep saying “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.”

Your code so far

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

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

const checkForStraights = (arr) => {
  const counts = {};

  for (const num of arr) {
    counts[num] = counts[num] ? counts[num] + 1 : 1;
  }

  
  const smallStraight = Object.keys(counts).join('').includes(1234 || 2345 || 3456);
  const largeStraight = Object.keys(counts).join('').includes(12345 || 23456);

  if (smallStraight) {
    updateRadioOption(3, 30);
  }

  if (largeStraight) {
    updateRadioOption(4, 40);
  }

  updateRadioOption(5, 0);

console.log(largeStraight);
console.log(smallStraight);

};

let array = [4, 2, 3, 5, 1]
let array2 = [6, 2, 4, 5, 3]

checkForStraights(array2);

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/130.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 14

Hi there!

Incorrect Use of || in .includes: The expression .includes(1234 || 2345 || 3456) does not work as intended because 1234 || 2345 || 3456 will evaluate to 1234 (the first truthy value). You need to check each possible straight individually.

Using Object.keys(counts).join('') may not give the numbers in ascending order, as the Object.keys() method doesn’t guarantee order.
The numbers in Object.keys(counts) will be strings, so joining them might not directly match your desired straight sequence.