# Pending test cases

Tell us what’s happening:
The following test cases are not working :

• Cards Sequence 7, 8, 9 should return `0 Hold`

• Cards Sequence 3, 7, Q, 8, A should return `-1 Hold`

• Cards Sequence 2, J, 9, 2, 7 should return `1 Bet`

All these cases involve 7,8,9 for which the value of count does not change.

``````
var count = 0;

function cc(card) {
// Only change code below this line
if(card<7 && card>1)
count++;

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

if(count>0)
return count + " Bet";
else
return count + " Hold";

// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

``````

User Agent is: `Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0`.

Challenge: Counting Cards

`card == 10 || 'J'` is not doing what you think
this is " if `card` is 10 OR if “J” is truthy"

try:

``````let card = 7
let result = card == 10||'J'||'Q'||'K'||'A'
console.log(result) // this doesn't give false - you need to change condition
``````

Thank you for replying but I am unable to understand the mentioned mistake .
For case card=7, the statement else if(card == 10||‘J’||‘Q’||‘K’||‘A’) should return false and hence the value of count stays unchanged.

but it doesn’t evaluate to false, that’s the issue

that’s why I suggested you play a bit with that code snippet

``````let card = 7;
console.log(card == 10) // false
console.log(card == 10 || "J") // this is not false
``````

you can’t convert the sentence “if card is equal to 10 or “J”” exactly like that in code
in code it must be “if card is equal to 10 or card is equal to “J””

1 Like

I see what you meant, card==10 being false the console simply logs the second case i.e. ‘J’. The following solutions solves all the test cases:

``````if(card>1 && card<7)
count++;
else if(card == 10 || card =='J' || card =='Q' || card =='K' || card =='A')
count --;
``````

I also tried the following in an editor:

``````let card = 7;
console.log(card ==( 10 || "J"));  // logs false
``````

However, the following solution doesn’t work

``````else if(card == (10 || 'J' || 'Q' || 'K' || 'A'))
count --;
``````
• This clears the test cases for count++ and when the card is 7,8,9.

• But the cases where the count should decrease aren’t working.

it evaluates first inside the parenthesis, so card is compared with only one of the values, not with all of them

`==` compare with one value, there is no way to change this, doesn’t matter what you try

Got it. Thank you. 