Tell us what’s happening:
The lab environment accepts my code as a solution and says it passes all tests, but according to the console, it doesn’t pass all of them.
Here are the tests the solution does NOT pass:
-
After the cards 2, 3, 4, 5, then calling cc(6) should return the string 5 Bet. (Output is: 1 Bet)
-
After the cards 10, “J”, “Q”, “K”, then calling cc(“A”) should return the string -5 Hold. (Output is: -1 Hold)
-
After the cards 2, “J”, 9, 2, then calling cc(7) should return the string 1 Bet. (Output is: 0 Hold)
-
After the cards 2, 2, then calling cc(10) should return the string 1 Bet. (Output is: -1 Hold)
I’m not completely satisfied here. Sure, I gave a “passable solution”, but the code technically still doesn’t work. Is there an extra string I need to return? Some math that I’m missing? Not sure which direction to take to make the solution complete.
I appreciate the help in advance. Cheers.
Your code so far
let count = 0
function cc (card) {
if (card >= 2 && card <= 6) {
++count;
} else if (card >=7 && card <=9) {
count;
} else if (card === 10 || card === "J" || card === "Q" || card === "K" || card === "A") {
--count;
}
if (count > 0) {
return `${count} Bet`
} else if (count <= 0) {
return `${count} Hold`
}
}
let valueDecision = cc()
console.log(valueDecision)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Challenge Information:
Build a Card Counting Assistant - Build a Card Counting Assistant