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