Instead of using an if statement at the end of switch, can I just return the count and string (Bet or Hold) after case? I tried and doesn’t work, but I’m not sure I understand why we can’t do that. Thanks!
**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++;
//return count + " Bet";
break;
case 7:
case 8:
case 9:
//return count + " Hold";
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
//return count + " Hold";
break;
}
if (count > 0){
return count + " Bet";
}
else {
return count + " Hold";
}
// Only change code above this line
}
console.log(cc(2)); console.log(cc('J')); console.log(cc(9)); console.log(cc(2)); console.log(cc(7));
console.log(count);
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36
Challenge: Counting Cards
Link to the challenge: