# Counting Cards how to do solve?

Tell us what’s happening:

help,why is it not work?

``````
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 7:
case 8:
case 9:
break;
case 10:
case J:
case Q:
case K:
case A:
count -1;
break;
}
return count + "Bet";
}else
return count + "Hold";

return "Change Me";
// Only change code above this line
}

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

User Agent is: `Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36`.

In your switch statement, the cases for J, Q, K and A should be wrapped in quotes (like `'J'`, etc.). Fixing them will not yet pass though.

have fix ‘J’,but can’t work.I don’t why?
// running tests

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

• What’s the use you have of `answer`? You write `count = answer` but then you change `count` so you can’t evaluate `answer` anymore as it is not equal to `count` anymore

• `count -1` is not how you lower the value of a variable by one

• You are missing a space in your output between `count` and the word you need to return

I have delete answer and count -1,but can’t work. `:confounded:`

Post again your code, so we can see what you have changed

Hint
Do NOT reset `count` to 0 when value is 7, 8, or 9.
Do NOT return an array.
Do NOT include quotes (single or double) in the output.
see it,don’t single or double,and count to 0 when value 7.8.9.
so how to solve?

That’s not your code , if I don’t see your code I don’t know what’s wrong

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/counting-cards
I try change it, but can’t work.

Like in the first post you included your code, you need to do it again

Click the `</>` preformatted text button and paste your code

Tell us what’s happening:

@ieahleen why can’t work??

``````
var count = 0;

function cc(card) {
// Only change code below this line
switch(card) {
case 2: case 3: case 4: case 5: case 6:
return "5 Bet";
break;
case 7: case 8: case 9:
return "0 Hold";
break;
case 10: case J: case Q: case K: case A:
return "-5 Hold";
break;
case 3: case 7: case Q: case 8: case A:
return "-1 Hold";
break;
case 2: case J: case 9: case 2: case 7:
return "1 Bet";
break;
case 2: case 2: case 10:
return "1 Bet";
break;
case 3: case 2: case A: case 10: case K:
return "-1 Hold";
break;
}
if (count > 0) {
return count + "Bet";
} else {
return count + "Hold";
}

return "Change Me";
// Only change code above this line
}

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

User Agent is: `Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36`.

You have changed anything - you were more near it before

You are not updating the value of `count`… you are just trying to get the correct result for the tests - well, it will not work: your function accepts one card, count needs to be updated depending on the card value and then depending on count you return `Bet` or `Hold`

Your function is just returning `5 Bet`, `0 Hold` or `-5 Hold`, no other values can be returned from your function, and it is not updating `count`

I’m still confused,if write switch(card) { case 2: case 3: case 4: case 5: case 6: count++; break; case 7: case 8: case 9: 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 don’t think it will work??

You are missing a space on the return statement (you are returning `5Bet` instead of `5 Bet`)

still can’t work, confused.