Tell us what’s happening:
I am finding it hard to understand the following:
-
After the cards 7, 8, then calling cardCounter(9) should return the string 0 Hold.
-
After the cards 10, “J”, “Q”, “K”, then calling cardCounter(“A”) should return the string -5 Hold.
-
After the cards 3, 7, “Q”, 8, then calling cardCounter(“A”) should return the string -1 Hold.
-
After the cards 3, 2, “A”, 10, then calling cardCounter(“K”) should return the string -1 Hold.
Your code so far
let count = 0;
function cardCounter(card){
if (card === 2 || card === 3 || card === 4 || card === 5 | card === 6){
count = count +1
}else if (card === 7 || card === 8 || card === 9){
count;
}else if (card === 10 || card === "J" || card === "Q" || card === "K" ||
card === "A"){
count = count -1
}
if (card > 0){
return `${count} Bet`;
}else if (card <= 0){
return `${count} Hold`
}
};
console.log(cardCounter(2));
console.log(cardCounter(3));
console.log(cardCounter(4));
console.log(cardCounter(5));
console.log(cardCounter(6));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
Challenge Information:
Build a Card Counting Assistant - Build a Card Counting Assistant