When i run tests my code seems to be working fine but it still fails the tests. i have tried multiple things but it still does not pass the test. Please help.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function checkForStraights(numbersArray) {
let countingArray = [];
let arrayCounter = 0;
const isAwin =()=>{
if(countingArray.length === 4){
updateRadioOption(4, 40);
updateRadioOption(3, 30);
return true;
}
else if(countingArray.length === 3){
updateRadioOption(3, 30);
return true;
}
}
for(let i = 1; i < 5; i++){
if(numbersArray[i] - numbersArray[i - 1] ===1){
countingArray[arrayCounter] = 1;
console.log(countingArray);
arrayCounter++;
}
}
if (isAwin()) return;
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([1,2,3,4,7]);
}
});
// 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/127.0.0.0 Safari/537.36 Edg/127.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14
I have tried multiple tests and they all result in the right output in the console so i know that my function is properly checking for large straights and small straights.
and on top of that the program shows that the right value and index are being passed into the updateRadioButton () function when i use test cases that pass as either large straight or small straight.
i attached an image for the errors i am getting in console
Earlier you said you tested the code and it was working?
Then I suggested you try a different test.
I gave you a list of numbers to try.
The idea is, you should try it and see what happens. The list I gave you is a large straight. So if your code is working, then it will recognize this and update the appropriate options.
Ok i understand now. I read the instructions wrong from the beginning so my code does what i thought it should be doing right but not what it should be really doing for it to pass. My code only checks for numbers in order that come one after the other not the ones that come in any order like the ones in the list you gave me. Thank you. I will go back and create a new algorithm from scratch and if i encounter any issues i will get back to you.