# I can't seem to get a grasp with the counting cards challenge

Tell us what’s happening:
Describe your issue in detail here.

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

function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6){
return "5 Bet";
} else if (card === 10 && card === 'J', 'Q', 'K', 'A'){
return "-5 Hold";
} else if (card === 7 && card === 8 && card === 9){
return "0 Hold";
} else if (card === 3 && card === 7 && card === 'Q' && card === 8 && card === 'A'){
return "-1 Hold";
}
if (count > 0){
return count + "Bet";
} else{
return count + "Hold";
}

// 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; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36`

Challenge: Counting Cards

It looks like you’re trying to hard code the solutions to the specific test cases given to you, but your code needs to be written more generally.

The function needs to do two things.

First, if the `card` is 2, 3, 4, 5, or 6, then increase `count` by one. If the `card` is 10, J, Q, K, or A, then decrease `count` by one.

Second, you need to return a string based on the value of `count`. The string should consist of the current value of `count`, followed by either the word Bet or Hold, depending on if `count` is positive or not.

Does that clarify anything?

Thank you for the clarification. This is what I have now.

let count = 0;

function cc(card) {
//Only change code below this line
if (card >= 2 && card <= 6){
return count++;
} else if (card === 10 && card ===‘J’, ‘Q’, ‘K’, ‘A’){
return count–;
}
if (count > 0){
return count + “Bet”;
} else if (count < 0) {
return count + “Hold”;
}
// 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.