Still being rejected after rewriting code 4-5 times

Tell us what’s happening:
for some reason my code is still being rejected even after using switch, if, and if else function.

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:
 return count+=1;
case 7:
case 8:
case 9:
 return count+=0;
case "10":
case "J":
case "Q":
case "K":
case "A":
 return count-=1;

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

return "Change Me";
// Only change code above this line

cc(2); cc(3); cc(7); cc('K'); cc('A');

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.

Challenge: Counting Cards

Link to the challenge:

one thing is that you should be changing the return statement that says return “Change Me”;

The biggest problem here is you have return statements inside your switch. As soon as a return statement executes, the function exits. The break statement is fine, but remove the return before each of your lines that change the count value.

The last return "Change Me" will never be executed, so it can be removed. It is not the source of your problem.


No need to group anything with braces here.


I don’t know that braces improve readability here. I personally have seen far more switches without braces than with. I think the ‘readability’ comes down to what is the predominant style in the codebase.

I will see what? Your style is perfectly fine, but it’s different that what people typically use, which makes it less readable unless you are working in a codebase where the extra braces are always added.

where should i remove the braces from the code?

I was replying to the other user.

i have removed that statement and the lesson still says my answer is incorrect

What does your code currently look like?

i figured it out I was missing a space in between the quotation marks in the Bet and Hold string. I originally had it like this “Bet” and “Hold” when it was supposed to be " Bet" and " Hold"

1 Like