# Counting Card code works everywhere except in one line

I have this code that should return different strings for various variations. It works in every line except in:

case 3, 7, “Q”, 8, “A”:
return “-1 Hold”;

it says : Cards Sequence 3, 7, Q, 8, A should return the string -1 Hold
And I don’t know why

``````   **Your code so far**
``````
``````

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2, 3, 4, 6:
return "5 Bet";
case 7, 8, 9:
return "0 Hold";
case 10, "J", "Q", "K", "A":
return "-5 Hold";
case 3, 7, "Q", 8, "A":
return "-1 Hold";
case 2, "J", 9, 2, 7:
return "1 Bet";
case 2, 2, 10:
return "1 Bet";
case 3, 2, "A", 10, "K":
return "-1 Hold";
default:
return "Change Me";}
// Only change code above this line
}

cc(2); cc(3); cc(7); cc('K'); cc('A');
``````
``````   **Your browser information:**
``````

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

Challenge: Counting Cards

You are trying to hard code the solution, but that will not work. You have to create two pieces of logic in the following order to solve this challenge.

1. Increment/Decrement the `count` depending on the value of the card.
2. Based only on the `count` value calculated above, return a string containing the value of `count` followed by a space and then the applicable word `Bet` or `Hold`. The `Hold` and `Bet` part returned is independent of the card value.
1 Like

Thank you sir, here are my results =>

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 += 1

break;

case 7:

case 8:

case 9:

count += 0;

break;

case 10:

case “J”:

case “Q”:

case “K”:

case “A”:

count -= 1

break;

default:

return (“Change Me”);

}

if(count <= 0) {

return count + " Hold";

} else {

return count + " Bet";

}

// Only change code above this line

}

cc(2); cc(3); cc(7); cc(‘K’); cc(‘A’);

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