Help me javaScript counting cards

Tell us what’s happening:
the problem is only in Cards Sequence 2, J, 9, 2, 7 should return 1 Bet

Your code so far


var count = 0;
var  decision ="";
var i=0;
function cc(card) { 
  // Only change code below this line 
  switch (card){  
    case (2||3||4||5||6): i=1;break;
    case (7||8||9):i=0;break;
    case(10||'J'||'Q'||'K'||'A'):i=-1;break;
  }
  count+=i;
  if (count <=0) {decision="Hold"}else decision="Bet";
  return(count+" "+decision) 
}


Those are not legal case statements.

1 Like

You cannot use the || operator in a switch/case statement, you have to make a case for each instance.