Counting Cards error with 2.3,4,5,6 sequence

Hello friends im stuck with this challenge i made my code but it shows this

“Cards Sequence 2, 3, 4, 5, 6 should return 5 Bet”

so i made an console.log to see what the count is when i enter that secuence and its 6 i dont know why since it start with count in 0 and add +1 five times.


var count = 0;

function cc(card) {

switch (card) {
  case 2:
  count+=1;
  break;
  case 3:
  count+=1;
  break;
  case 4:
  count+=1;
  case 5:
  count+=1;
  break;
  case 6:
  count+=1;
  break;
  case 7:
  count+=0
  break;
  case 8:
  count+=0
  break;
  case 9:
  count+=0
  break;
  case 10:
  count-=1;
  break;
  case 'J':
  count-=1;
  break;
  case 'Q':
  count-=1;
  break;
  case 'K':
  count-=1;
  break;
  case 'A':
  count-=1;
  break;
}

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

cc(2); cc(3); cc(4); cc(5); cc(6);
console.log(count)

Maybe because you don’t have a break in your case 4:.

1 Like