Tell us what’s happening:
Really stuck on this one. All the previous solutions seem to not be updated. For instance, for the first one Cards Sequence 2, 3, 4, 5, 6 should return the string 5 Bet. I tried before to write case 2 (all the way to 6) then return ‘5 Bet’ and then break. It shown it was correct, and I did it for the others too until I got to the ones where it had either the same numbers or letters. Then it stopped working. I had to erase that solution when I remembered the return value isn’t supposed to be in the switch statement. Now I’m completely stuck on this problem. Any help is much appearicated.
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:
card = '5 Bet';
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
i think you probably misunderstand the game.
For cards 2, 3, 4, 5, 6 the card changes by +1,
for cards J, Q, K, A, 10 the card changes by -1,
For cards 7, 8, 9 the card doesn’t not change
In addition, if the current count based on the above is positive then bet, and when the current count is zero or negative then hold
This is what I did the first time around, but it didn’t allow me to go through. I think there are other things that have been added to the lesson. This is my current code.
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;
if (count > 0){
return count + " Bet"
} else {
return count + " Hold"
}
I think this is the solution to what you’ve mentioned but it doesn’t work on this lesson anymore.
When posting code, please insert it between backticks to make it more readable.
You can do this by clicking on the </> and pasting your code where indicated.
Aside from the decrement error mentioned in the previous response, your code (above) is correct except that you haven’t closed off your switch statement properly (before your conditional statement).