Tell us what’s happening:
My code is not passing the below 2 tests. Please help. I want to know where I a going wrong in my code. I have checked solutions to this code but I specifically want to know why my code is not working. Appreciate you support.
-
Cards Sequence 2, J, 9, 2, 7 should return the string
1 Bet
-
Cards Sequence 2, 2, 10 should return the string
1 Bet
Your code so far
let count = 0;
function cc(card) {
switch (card){
case 2:
count += 1
return count + ' Bet';
break;
case 3:
count += 1
return count + ' Bet';
break;
case 4:
count += 1
return count + ' Bet';
break;
case 5:
count += 1
return count + ' Bet';
break;
case 6:
count += 1
return count + ' Bet';
break;
case 7:
count += 0
return count + ' Hold';
break;
case 8:
count += 0
return count + ' Hold';
break;
case 9:
count += 0
return count + ' Hold';
break;
case 10:
count = count -1;
return count + ' Hold';
break;
case 'J':
count = count -1;
return count + ' Hold';
break;
case 'Q':
count = count -1;
return count + ' Hold';
break;
case 'K':
count = count -1;
return count + ' Hold';
break;
case 'A':
count = count -1;
return count + ' Hold';
break;
}
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.63
Challenge: Basic JavaScript - Counting Cards
Link to the challenge: