Basic JavaScript - Counting Cards

How come my code isn’t including the strings I added to the count when I console.log?

let count = 0;
function cc(card) {

var cardNames= “J” + “Q” + “K” + “A”

if (card > 0 && card < 7) {
return count ++;

} else if (card === 10 || card === “J” && “Q” && “K” && “A”)
return count --;

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

}
}
cc(2); cc(3); cc(4); cc(6); cc(“A”);
console.log(cc(“J”));

Please post your actual code instead of a screenshot. Thanks

This comparison doesn’t work as you intended.

It gives me the right value when calling the function, but I can’t figure out why it doesn’t add to the “count” whether, to “bet” or “hold” if the count is less than or greater than 0

That comparison is not correct. It’s wrong.

Ok how can I fix it to display the correct count and display whether to bet or hold?

I cannot write the answer for you.

What is that comparison supposed to do? Why did you write it differently than the other if statement?

I wrote it differently because of the strings of the other types of blackjack cards I can’t put it as the same comparison as 4 of the cards are strings and not integers. That’s why I tried creating a variable that has all of them defined so when I console.log it gives me the correct count

Why can’t you use the same type of comparison? I don’t remember a previous lesson that said that?

I’d try writing the comparison the same way as you did with the numbers.

Because you can’t have less than or greater than a string because it isn’t an integer right? And even if I do change the comparison the comparison I wrote still gave me the correct values the issue i’m having is that it is not putting my added strings to my return statement at the end.

Nope. But you can check equality like you did with the number.

It doesn’t. The comparison is wrong. It gives bad values of count

Ok after testing it again you are right it’s not giving the right values I can’t figure out how to fix it thanks for trying to help

Like I said above, you need to use these valid comparisons, not the invalid usage of &&

ok I tried it using or comparisons but I encountered the same issue where it doesn’t display whether to bet or hold

Why did you stick || in there?

You need to check for each value separately, like you did with the 10 and J

I did try making serperate else if statements but the code kept on running errors

You do not need more if-else statements. You need more comparisons.

if (letter === "A" || "B")

Is invalid

if (letter === "A" || letter === "B")

Is valid

To put it another way, this was never shown in previous steps as valid syntax

Ok I got it to work but only when I don’t put a value into the console log, if I put a value into the console log it still won’t show whether to bet or hold.

let count = 0;
function cc(card) {

var cardNames= "J" + "Q" + "K" + "A"

if (card > 0 && card < 7) {
    return count ++;
    
} else if (card === 10||card==="J"||card==="Q"||card==="K"==="A")
return count --;

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

}
}
cc(2); cc(10); cc("J"); cc("K"); cc("A");
console.log(cc(3));

So why have return here?