# Counting Cards challenge, javascript doubt

Challenge : freeCodeCamp Challenge Guide: Counting Cards
Hello everyone, i’m still trying to figure out why on this code:

``````// Note: Only the last will display
cc(7); cc(8); cc(9); cc('K'); cc('A');
``````

why only the last value is going to show.
Someone can help me?

Try running it somewhere else. I think that its because the freecodecamp people did something behind the scenes. I wouldn’t wory about it too much.

You should ask this question as a seperate thread, because I’ve noticed that it
applies to many exercises, and you probably won’t get that many people who know the reason in this one.

1 Like

Well, i wrote using “document.write()”, and it showed everything, yep they did something, thanks for helping!
I thought that my logic was broken.

1 Like

Can someone explain the challenge? I didn’t understand the challenge only?

I came out with this solution, worked. Hope you find it useful.

``````var count = 0;

function cc(card) {

const low = [2, 3, 4, 5, 6];
const high = [10, 'J', 'Q', 'K', 'A'];
if (low.includes(card)){
count++;
} else if (high.includes(card)) {
count--
}
if (count <= 0) {
console.log(count + " Hold");
return count + " Hold";
} else {
console.log(count + " Bet");
return count + " Bet";
}

}

cc(2); cc(3); cc(7); cc('K'); cc('A');
``````

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with `[spoiler]` and `[/spoiler]` tags on the line above and below your solution code.