I’m not sure if the way I’ve completed this challenge is the right way? As some things are not working such as the codes not resetting each time, the hold and bet strings are not going in the right place.
Just watched the video this was very simple, I forgot that i could use “case”
Here’s the answer
var count = 0;
function cc(card) {
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++; // Cards from 2 to 6, add 1 each time
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--; // Cards from 10 to A, Subtract 1 each time
break;
}
var holdbet = "Hold"
if (count > 0) {
holdbet = "Bet"
}
return count + " " + holdbet;
}
cc(2); cc(3); cc(7); cc('K'); cc('A'); // Returns 1
the issue is that you are using the value of card to determine if the returned value needs to contain Bet or Hold
instead you need to use the value of count to determine that
Your solution is fine! My first solution was a lot messier. Remember there are many ways to code a certain thing, and just because you didn’t come up with the same solution as the video doesn’t mean you’re “wrong”. In this case, if statements work just as fine as switch/case statements!