Its displaying error actually it should output hold or bet

Tell us what’s happening:

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 7:
 case 8:
 case 9:
 case 10:
 case "J":
 case "K":
 case "Q":
 case "A":
 count--;
 break;
}
 var holdbet="Hold";
 if(count>0){
   holdbet="bet";
 }
return count+" "+ holdbet;
}

// Only change code above this line


cc(2); cc(3); cc(7); cc("K"); cc("A");
cc(7);cc(8);cc(9);
cc(10);cc("J");cc("Q");cc("K");cc("A");
cc(3);cc(7);cc("Q");cc(8);cc("A");
cc(3);cc(7);cc("Q");cc(8);cc("A");
cc(2);cc("J");cc(9);cc(2);cc()7;
cc(2);cc(2);cc(10);
cc(3);cc(2);cc("A");cc(10);cc("K");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Challenge: Counting Cards

Link to the challenge:

The function itself works, but you are defining count globally, so if you run cc(2), then cc(3) the return value will be 1 bet, then 2 bet respectively.

cc(2);cc(“J”);cc(9);cc(2);cc()7;

Although the “cc()7” will produce an error :sweat_smile:

Also, you changed code below the Only change code above comment and you should double check your capatalization.

i didnt see that cc()7,Thanks for pointing it out .

do they want you to return 1 bet or 1 Bet?

they want me to return 1 Bet

but you are returning the other one, so make the change to fix that!