Basic JavaScript - Counting Cards

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

I am getting an issue where it does not work for the following sequences
7,8,9
3,7,Q,8,A
2,J,9,2,7
I know i can do it with switch statements but i am curious to know why this method does not work if any one can see why

Your code so far

let count = 0;

function cc(card) {
  // Only change code below this line
  if (card <= 6 && card >= 2) {
    count ++;
  } else if (card == 10,"J","Q","K","A") {
    count --;
  } else if (card <= 9 && card >= 7){
    count;
  }

  var holdbet;
  if (count >= 0){
    holdbet = "Bet";
  } else if (count < 0){
    holdbet = "Hold"
  }
  return count + " " + holdbet;
  // Only change code above this line
}
console.log(cc(7),cc(8),cc(9));


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.57

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

got the answer in the forum its the second else if
it should be (card == 10 || (card>="A "&& card<= “Q”))

} else if (card == 10 || card == “J” || card == “Q” || card == “K” || card == “A”) {

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.