Tell us what’s happening:
Hi there,
I would appreciate any pointers in the right direction. I have been unable to get my code to pass steps 8 and 9.
- After the cards 2, “J”, 9, 2, then calling cardCounter(7) should return the string 1 Bet.
- After the cards 2, 2, then calling cardCounter(10) should return the string 1 Bet.
Saw someone asked a question in the forum with similar code using if/elseif statements but can’t quite pinpoint where I have deviated.
Your code so far
let count = 0;
function cardCounter(card){
if (card ===2 || card === 3 || card === 4 || card === 5 || card ===6 ) {
return`${++count} Bet`
} else if (card === 7 || card=== 8 || card=== 9) {
return `${count} Hold`
} else if (card === 10 || card === "J" || card==="Q" || card==="K" || card==="A") {
return `${--count} Hold`
}
}
cardCounter(2)
cardCounter(3)
cardCounter(4)
cardCounter(5)
console.log(cardCounter(6))
count=0;
cardCounter(7)
cardCounter(8)
console.log(cardCounter(9))
count=0;
cardCounter(10)
cardCounter("J")
cardCounter("Q")
cardCounter("K")
console.log(cardCounter("A"))
count=0;
cardCounter(3)
cardCounter(7)
cardCounter("Q")
cardCounter(8)
console.log(cardCounter("A"))
count=0;
cardCounter(2)
cardCounter("J")
cardCounter(9)
cardCounter(2)
console.log(cardCounter(7))
count=0;
cardCounter(2)
cardCounter(2)
console.log(cardCounter(10))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Challenge Information:
Build a Card Counting Assistant - Build a Card Counting Assistant