I used the switch method to evaluate different values for the card variable. If the card is b/w 2 and 6, it should add 1 to the count and if it’s b/w 10 and “A”, it should subtract 1 from the count. After that I used the if/else method so if the count is greater than 0 it should return count + " Hold";
It seems right but I can’t get my code to pass at all. Does anyone spot anything wrong?
Your code so far
let 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++;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
return count--;
break;
}
if (count > 0) {
return count + " Bet";
} else {
return count + " Hold";
}
// 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_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15
Challenge: Basic JavaScript - Counting Cards
Link to the challenge: