# Counting Cards project can't work

Tell us what’s happening:

``````  **Your code so far**
``````
``````
var count = 0;

function cc(card) {
// Only change code below this line
var count = 0;

function cc(card) {
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;
}

var holdbet = 'Hold'
if (count > 0) {
holdbet = 'Bet'
}

return count + " " + holdbet;

}

// Only change code above this line
}

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

I did the help in the video and still not working in my work

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36`.

Challenge: Counting Cards

In what way is it not working?

When I insert the code I don’t get it correct but keep telling me a lot of stuff

Well, what is the stuff it is saying? It looks like you may have copy-pasted the solution into the challenge without putting it in the right place.

1 Like

Cards sequence 2, 3,4,5,6 should return 5 Bet
Cards sequence 10,J,Q,K,A should return the string -5 Hold and a lot more

``````var count = 0;

function cc(card) {
// Only change code below this line

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

In your code, you have created another variable named `count` and yet another function named `cc`. The outer function does not explicitly return a value, so for every call to the function `cc`, you are returning `undefined`. I would start by not creating the inner `count` variable and not defining yet another function named `cc`. The code inside your inner `cc` function looks like it might be fine as the only code inside the original outer `cc` function.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.