Tell us what’s happening:
Hello and thank you for your time. This code is running and gives the expected results. But I cant pass the 2nd test for a reason. If a small straight is rolled, enable the 4th button and set the value to 30, display text to , score = 30 and leave 5th button disabled. The only thing I didnt do is to disable the 5th button because it is already disabled.
Thank again for your time and your help.
Also added scoreInputs[4].disabled = true; to disable 5th button… Still can not pass the 2nd test.
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const noDuplicates = (arr) => [...new Set(arr)];
const sortArr = (arr) => {
return arr.sort((a, b) => a - b);
}
const checkForStraights = (arr) => {
arr=sortArr(arr);
arr=noDuplicates(arr);
console.log(arr,arr.length);
if (arr.length === 4) {
for(let i=0; i<arr.length-1; i++){
if(arr[i+1]!=arr[i] + 1){
return false, console.log(false);
}
}
console.log("Straight", arr);
updateRadioOption(3,30)
} else if (arr.length === 5) {
for(let i=0; i<arr.length-1; i++){
if(arr[i+1]!=arr[i] + 1){
return false, console.log(false);
}
}
console.log("Straight", arr);
updateRadioOption(3,30)
updateRadioOption(4,40)
} else {
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
/* file: styles.css */
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