# Counting Cards problem driving me crazy

Counting Cards problem driving me crazy
0

what the hell is the problem here!!!

``````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:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
return count + " Hold";
break;
}

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');
``````

Context is very important, specify what is the problem that youâ€™re having so you can be helped properly

What you return should be based on the value of `count`. You are currently determining it based on the value of `card`.

1 Like

i dont understandâ€¦

now i understand i shouldnt have used return in switch but in a separate line with an if statement but i dont understand why?

There is nothing inherently wrong with having a `return` in a `switch`, but the logic of this one is wrong. Whether you return â€śBetâ€ť or â€śHoldâ€ť should be based on what the value of `count` is. Your code returns â€śBetâ€ť if `card` is less than 7, no matter what `count` is. It returns â€śHoldâ€ť if `card` is more than 6, no matter what `count` is.

2 Likes

ohhh now i get it.its pretty simple actually.thanksssssssssssssss