Tell us what’s happening:
Describe your issue in detail here.
**Your code so far**
var count = 0;
function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++ ;
break
case 10:
case "J":
case "Q":
case "K":
case "A":
count-- ;
break;
}
var betHold = "Hold";
if(count>0){
betHold="Bet";
}
return count+" "+betHold ;
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
console.log(cc(2,3,4,5)+cc('A'))
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
I don’t understand what you mean that the count it no shown.
The function is supposed to return a string with the count and the action. The word “count” here is not meant literally. You are not counting the cards in the sense of 1, 2, 3, 4, etc. You are giving a number that tells the player what the surplus is of good cards versus bad cards. (A black jack player likes a lot of 10, J, G, K, and A - it increases their odds of winning so they know to bet more.)
Your given function does that it is suppose to:
console.log(cc(3));
// 1 Bet
console.log(cc(7));
// 1 Bet
console.log(cc('Q'));
// 0 Hold
console.log(cc(8));
// 0 Hold
console.log(cc('A'));
// -1 Hold
This is exactly what we expect. It keeps a running “count” of the surplus of good cards and the suggested action. It is a running count because the variable count is global so it gets reused for each call, “remembering” its previous value.