Tell us what’s happening:
I don’t understand clearly,
2. If a small straight is rolled, your checkForStraights function should enable the fourth radio button, set the value to 30, update the displayed text to score = 30 and leave the fifth radio button disabled.
3. If a large straight is rolled, your checkForStraights function should enable the fourth button, set the value to 30, update the displayed text to , score = 30. Additionally, the function should enable the fifth radio button, set the value to 40, and update
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const conNumSmallStraight = [1,2,3,4];
const conNumLargeStraight = [1,2,3,4,5];
// const getNum = {};
console.log(arr);
let countSmallStraight = 0
let countLargeStraight = 0
for(let i = 0; i <= arr.length; i++){
const checkSmall = arr.includes(conNumSmallStraight[i], 0);
const checkLarge = arr.includes(conNumLargeStraight[i], 0);
// console.log('Small ', checkSmall);
// console.log('Large ', checkLarge);
if(checkSmall){
// updateRadioOption(3, 30);
countSmallStraight++;
countLargeStraight++;
console.log(`Small\n==========`, countSmallStraight);
} else if(checkLarge){
// updateRadioOption(4, 40);
countLargeStraight++;
console.log(`Large\n==========`, countLargeStraight);
}
}
if(countSmallStraight === 4 && countLargeStraight === 4){
console.log('Count Small: ',countSmallStraight)
updateRadioOption(3, 30);
}else if(countLargeStraight === 5){
console.log('Count Large: ',countLargeStraight)
updateRadioOption(3, 30);
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([4,1,4,2,3]);
// checkForStraights([4,1,5,2,3]);
checkForStraights(diceValuesArr);
}
});
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14