sarru
February 10, 2026, 7:34pm
1
Tell us what’s happening:
After the cards 2, “J”, 9, 2, then calling cardCounter(7) should return the string 1 Bet.
Unable to get through to this step.
Your code so far
let count=0;
function cardCounter(card)
{
if(card === 2 || card === 3 || card === 4 || card === 5 || card === 6)
{
count ++;
}
else if (card === 7 || card === 8 || card === 9 ) {
count =0;
}
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";
}
}
console.log(cardCounter(2));
console.log(cardCounter(3));
console.log(cardCounter(4));
console.log(cardCounter(5));
console.log(cardCounter(6));
console.log(cardCounter(7));
console.log(cardCounter(8));
console.log(cardCounter(9));
console.log(cardCounter(10));
console.log(cardCounter("J"));
console.log(cardCounter("Q"));
console.log(cardCounter("K"));
console.log(cardCounter("A"));
console.log(cardCounter(3));
console.log(cardCounter(7));
console.log(cardCounter("Q"));
console.log(cardCounter(8));
console.log(cardCounter("A"));
console.log(cardCounter(2));
console.log(cardCounter("J"));
console.log(cardCounter(9));
console.log(cardCounter(2));
console.log(cardCounter(7));
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
dhess
February 10, 2026, 7:52pm
2
The global count variable should remain unchanged for the cards 7, 8, 9.
Is your code meeting this requirement?
1 Like
sarru
February 10, 2026, 7:58pm
3
I believe so as value is same as zero which is initial value of variable.
sarru
February 10, 2026, 8:08pm
4
showed passed now thanks for reply:)
i don’t understand why you repeated the declaring of parameter, ahh like the way you did it isnt it just repeating your code
console.log(cardCounter(2));
console.log(cardCounter(3));
console.log(cardCounter(4));
console.log(cardCounter(5));
console.log(cardCounter(6));
console.log(cardCounter(7));
console.log(cardCounter(8));
console.log(cardCounter(9));
console.log(cardCounter(10));
console.log(cardCounter(“J”));
console.log(cardCounter(“Q”));
console.log(cardCounter(“K”));
console.log(cardCounter(“A”));
console.log(cardCounter(3));
console.log(cardCounter(7));
console.log(cardCounter(“Q”));
console.log(cardCounter(8));
console.log(cardCounter(“A”));
console.log(cardCounter(2));
console.log(cardCounter(“J”));
console.log(cardCounter(9));
console.log(cardCounter(2));
console.log(cardCounter(7));
dhess
February 13, 2026, 9:24am
6
Welcome to the forum @davidmurimi398 !
Please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.
The easiest way to create a topic for help with your own solution is to click the Ask for Help button located on each challenge. This will automatically import your code in a readable format and pull in the challenge url while still allowing you to ask any question about the challenge or your code.
Thank you.
system
Closed
March 13, 2026, 9:25am
7
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.