I was able to solve this question by changing the code a little but I want to know how this logic is wrong.
let count = 0;
function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count = count + 1;
break;
case 7:
case 8:
case 9:
count = 0;
break;
case "K":
case "Q":
case "J":
case "A":
case 10:
count = count - 1;
break;
}
if (count <=0){
return count + " Hold";
} else {
return count + " Bet";
}
return "Change Me";
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
The error I’m getting is
Cards Sequence 2, J, 9, 2, 7 should return the string 1 Bet