Counting Cards exercise help needed

Hello everybody! I’m trying to do the Counting Cards challenge but I’m having trouble with letters ( J, Q, K , A ) , the console keep printing this message
ReferenceError: J is not defined.
Can’t figure out what i’m doing wrong,

``````
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++;
return count + " Bet";
break;

case 7:
case 8:
case 9:
return count + " Hold";
break;

case 10:
count--;
return count + " Hold";
break;

case 'J':
case 'Q':
case 'K':
case 'A':
count--;
return count + " Hold";
break;
}

// Only change code above this line
}

console.log(cc(J));

``````

your issue is not with the letters, the issue is that the string you are returning is based on the card, instead it should be based only on the value of `count`

The function will then return a string with the current count and the string `Bet` if the count is positive, or `Hold` if the count is zero or negative. The current count and the player’s decision ( `Bet` or `Hold` ) should be separated by a single space.

Hello @ieahleen, i’ve changed the parameter but still not working

I think that’s not the problem cause i get passed almost all the tests,
only two get wrong:
Cards Sequence 2, J, 9, 2, 7 should return `1 Bet`

Cards Sequence 2, 2, 10 should return `1 Bet`

Like @ieahleen said, the error is that your function returns “Hold” or “Bet” based on the last card dealt (the last value passed in to the function) instead of on the `count` variable.

The test you are failing returns `1 Hold` instead of `1 Bet`, because the last card is 10 and that is how it determines the string.

really sorry but I don’t understand the problem, "10 " supposed to hold?
or the function has to return the result of all cards ?? I don’t really know blackjack, and my mother languaje its spanish so … maybe i’m not understanding what the function should do …

Yes, the function needs to return the result of all the cards. That’s why your “Hold” or “Bet” should be based on the `count` variable, as the `count` variable is keeping track of the cards that have passed through the function (sort of).

In blackjack, counting cards is used to gain an advantage - I count cards by watching the cards that are dealt. For low cards, I add 1 to my total, and for high cards, I subtract 1. If my total is above 0, I know that I have a better chance of getting two high cards, so I bet higher. The function you are writing should accomplish this same goal.