# Counting cards mayhem

``````var count = 0;

function cc(card) {

// Only change code below this line

switch (card) {

case 2:

case 3:

case 4:

case 5:

case 6:

count++;

break;

case 10:

case "J":

case "Q":

case "K":

case "A":

count--;

break;

}

if (count > 0) {

return count + "Bet";

} else {

return count + "Hold";

}
i tried this and  other some else if statements i dont know what im doing wrong. feeling a little bit lost here

``````

What do the failing tests say? I suspect that you, at the very least, a missing a extra `" "` space in your return strings.

State should never be outside the function. Just remember it forever it will apply to everything you will learn in the future!

Try putting `count` inside the function

it fails all the returns and
Cards Sequence 2, 3, 4, 5, 6 should return

``````5 Bet
``````

Cards Sequence 7, 8, 9 should return

``````0 Hold
``````

Cards Sequence 10, J, Q, K, A should return

``````-5 Hold
``````

Cards Sequence 3, 7, Q, 8, A should return

``````-1 Hold
``````

Cards Sequence 2, J, 9, 2, 7 should return

``````1 Bet
``````

Cards Sequence 2, 2, 10 should return

``````1 Bet
``````

Cards Sequence 3, 2, A, 10, K should return

``````-1 Hold
``````

// tests completed

I suspect that you will be able to see the problem if you add a console log after a sample card sequence, like this:

``````cc(2); cc(3); cc(7); cc('K'); console.log(cc('A'));
``````

You need to add some space in your output to get it to display correctly.

that part is in the âdo not changeâ section. im telling you im really stumped on this one

To tie in to @JeremyLT`s solution, Iâve done the console.log for you. The result your function returns is shown at the bottom. How does it differ from the expected return?

1 Like

In this case, it is ok to change it, and it will show you whatâs wrong.

Just a small typo. Try: count + â Betâ with the whitespace (and same for âHoldâ)

1 Like

thatâs how the challenge is. any suggestions on how to change it?

Count should be outside the function - otherwise it resets to 0 every time the function gets called, which ruins the point of having a card-counting functionâŚ

Sure, given the purpose of the challenge is to learn `switch` statement, I would just test one function at the time. Testing the âchainâ here doesnât affect the testing in any way and doesnât give any valuable insights for the `switch`.

do you want to suggest it on github?