# Card Counting Question

I’ve seen the way they want it done and I get that, but I do not understand why this or some variation of it doesn’t work? It completely ignores the “if else” statement and adds 7, 8, 9 as the if statement. if I input cc(7) why would it completely ignore the statement where it is clearly listed? Thank you.

var count = 0;

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

if (2 || 3 || 4 || 5 || 6) {
count++;
}

else if (7 || 8 || 9){
count;
}

else{
count–; //This is written with two. This post shows as one.
}

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

else{
return count + " Hold";
}

}

looks like you aint testing against anything? do you mean this `if(card == 7 || card == 8)` because `if(7 || 8 || 9)` will always be true because there is no conditional statement

1 Like

I’m not sure. I’ve tried card === 7, 8, 9, card === 7||8||9 and other variants of that. Is it as simple as changing it to == rather than === to get it to work?

As of now, it only reads the first if statement and straight up ignores the other two. It reads the first statement fine though. I’ve run the debugger, and it returns to the first if statement even if the arguments don’t match.

I need it to add 1 to count if it’s any of the first arguments, not to count if it’s the else if, and to subtract if it’s the else. Right now it’s only adding and reading a 7, 8 or 9 as the count++.

it doesnt work like this you have to add a conditional for each statement like `card === 7 || card === 8`, you could do this…

it does this because your first statement is always true no matter what.

you could try this

``````if(card >= 2 && card <= 6) {
count++
}
else if(card >= 7 && card <= 9) {
null
}
else {
count--
}
``````
1 Like

So I don’t fully understand why you can’t just write in the numbers as arguments without writing “card ===” first, but it is an easy concept and mistake that I won’t make again. I was able to solve. Thank you!

1 Like

there is an order in which the operators evaluate. The `===` evaluate first, then the `||`, so if you do `card === "7" || "8" || "9"` you get `false || "8" || "9"` which I think evaluate to `"8"` but I am not sure if they solve left to right or right to left

1 Like

Thank you for the clarification!