Can someone please tell me what’s wrong with my code?! Thanks in advance!
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;
}
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Your code to count the cards is correct, but your logic to hold/bet is the issue. To follow up on what @ILM wrote. The purpose of the code is to first figure out what the total count is, then to make a hold/bet decision based on that count. Try breaking up your answer into two parts. Figure out the count, and then write some logic (I would use an If statement here) to get your pass/hold designation. Finally, return both parts in one statement per the requirements of the exercise. GL