On this challenge: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/counting-cards , I got all but two of the tests to pass. Here’s my code:
var count = 0;
function cc(card) {
// Only change code below this line
let retValue;
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
retValue = count.toString() + " Bet";
break;
case 7:
case 8:
case 9:
retValue = count.toString() + " Hold";
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count -= 1;
retValue = count.toString() + " Hold";
break;
}
return retValue;
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
The tests that aren’t passing are:
Cards Sequence 2, J, 9, 2, 7 should return `1 Bet`
and
Cards Sequence 2, 2, 10 should return `1 Bet`
What am I missing? I also tried if-else chain earlier but it made even less of the tests pass.