Tell us what’s happening:
function checkForStraights (arr) {
const sortedArr = arr.sort().map((a,b) => a+b);
let counted = sortedArr.filter((val)=> val === 1).length;
let counts = {};
sortedArr.forEach((num) => {
counts[num] = (counts[num] || 0) + 1;
});
let consecutiveObject = […Object.values(counts)];
if(consecutiveObject.includes(5)){
updateRadioOption(4, 40);
}else if(consecutiveObject.includes(4)){
updateRadioOption(3, 30);
}else{
updateRadioOption(5, 0);
}
rollDiceBtn.add
Your code so far
hola , tengo problemas para completar este codigo ya probe de muchas opciones pero no pasa nada.
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
function checkForStraights (arr) {
const sortedArr = arr.sort().map((a,b) => a+b);
let counted = sortedArr.filter((val)=> val === 1).length;
let counts = {};
sortedArr.forEach((num) => {
counts[num] = (counts[num] || 0) + 1;
});
let consecutiveObject = [...Object.values(counts)];
if(consecutiveObject.includes(5)){
updateRadioOption(4, 40);
}else if(consecutiveObject.includes(4)){
updateRadioOption(3, 30);
}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 (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