# Basic JavaScript: Counting Cards [Help!]

I have seen multiple solutions using "switch " and some "else if’ but I really want to make my code work. Would you mind taking a look? Thank you!

``````var count = 0;

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

if (card <=  6 && card <= 2) {
count  = count + 1 ;

return  count  + "Bet"
}
else  if (card <= 9 && card >= 7){
count = count  +  0 ;

return count + "Hold"

}

else if ( card = 10  ||  'J'  || 'Q ' || 'K' || 'A') {
count = count - 1 ;
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');

``````

You have a logic mistake in the above line. This if statement will only evaluate to true if the card is a 2.

You can not make multiple comparisons like you are trying to do above. You must compare each to card. Also, do not confuse the assignment operator with an equality operator. You may need to go back a few lessons to review the differences between the two operators.

Lastly, you need to separate the count increase/decrease logic from the logic around what to actually use in the return statement. Currently, you are mixing the two together which is a big problem. What determines a " Hold" or " Bet" is not dependent on the current card value. It is definitely dependent on the count value though.

randelldawson,

Tell us what’s happening:
I have been tackling this challenge for a few hours and I can’t get why it does not accept the following conditions:

Cards Sequence 10, J, Q, K, A should return -5 Hold
Cards Sequence 3, 7, Q, 8, A should return -1 Hold
Cards Sequence 3, 2, A, 10, K should return -1 Hold

``````
var count = 0;

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

if (card >=2 && card <=6)  {
count  = count + 1 ;

}
else  if (card >= 7 && card <= 9)  {
count = count  +  0 ;

}

else if ( card == 10||'J'||'Q'||'K'||'A') {
count = count - 1 ;
}

if (count > 0) {
answer = (count) + " Bet";

} else if (count === 0) {
answer = (count) + " Hold";
}
else if (count <= 0) {
}

// Only change code above this line
}

// Note: Only the last will display
cc(10); cc("J"); cc("Q"); cc("K"); cc("A");
``````

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36`.