Tell us what’s happening:
I’ve seen so far similar answer to mine, but still I’m trying to figure out what is wrong with my code.
Your code so far
let count = 0
function cardCounter(card){
if (card >= 2 && card <= 6){
return count += 1
}
else if (card >= 7 && card <= 9){
return count += 0
}
else if(card === 10 || card === 'A' || card === 'K' || card === 'J' || card === 'Q'){
return count -= 1
}
if(count >= 1){
return `Bet ${count}`
}
else if(count <= 0){
return `Hold ${count}`
}
}
console.log(cardCounter(6))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0
Challenge Information:
Build a Card Counting Assistant - Build a Card Counting Assistant
GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-counting-cards/68a23004e96a105df3a21fc4.md at main · freeCodeCamp/freeCodeCamp · GitHub
dhess
July 15, 2026, 3:27pm
2
Hi @edgshift ,
Why do you think you’re seeing 1 in the console?
Will your code ever reach the second if statement?
Is your final output formatted as asked?
Happy coding
I’m seeing 1 cause the count variable is incremented by 1, and the output format is such the example.
dhess
July 16, 2026, 3:30pm
4
Try adding logs inside your if and else statements like console.log("inside count>=1").
Do you see a message in the console for either log?
What happens in your code when you return?
Happy coding
dhess
July 16, 2026, 3:37pm
6
This is from the code you posted with logs added.
What good does it do you to force the output with console.log(cardCouter(-3))?
What point are you trying to make?