What’s wrong with my code? I know it’s certainly not the best solution, however I see it and I don’t know why I can’t pass all the tests.
Specifically, these two requirements are what I do wrong:
Cards Sequence 2, J, 9, 2, 7 should return the string 1 Bet
Cards Sequence 2, 2, 10 should return the string 1 Bet
The rest I do well apparently, but why exactly? I check it over and over again and I can’t find an error in the counter, thanks!
This is my code
let count = 0;
function cc(card) {
// Only change code below this line
switch (card) {
case 2:
count += 1
return count + " Bet"
break;
case 3:
count += 1
return count + " Bet"
break;
case 4:
count += 1
return count + " Bet"
break;
case 5:
count += 1
return count + " Bet"
break;
case 6:
count += 1
return count + " Bet"
break;
case 7:
return count + " Hold"
break;
case 8:
return count + " Hold"
break;
case 9:
return count + " Hold"
break;
case 10:
count -= 1
return count + " Hold"
break;
case "J":
count -= 1
return count + " Hold"
break;
case "Q":
count -= 1
return count + " Hold"
break;
case "K":
count -= 1
return count + " Hold"
break;
case "A":
count -= 1
return count + " Hold"
break;
// 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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Counting Cards
Link to the challenge: