Basic JavaScript - Counting Cards

i have used switch to try to complete the challenge but some of the conditions cant test correct. Please i need help

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 "5 Bet";
  break;
  case 7:
  case 8:
  case 9:
  return "0 Hold";
  break;
  case 10:
  case 'J':
  case 'Q':
  case 'k':
  case 'A':
  return "-5 Hold";
  break;
  case 3:
  case 7:
  case "Q":
  case 8:
  case "A":
  return "-1 Hold";
  break;
  case 2:
  case "J":
  case 9:
  case 2:
  case 7:
  return "1 Bet";
  break;
  case 2:
  case 2:
  case 10:
  return "1 Bet"
  break;
  case 3:
  case 2:
  case "A":
  case 10:
  case "K":
  return "-1 Hold";
  break;
}
  

  // 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

There are a few things that jump out at me.

  • You are not updating count. It is always going to be 0.
  • You are determining whether to return “Bet” or “Hold” based on what card is. That should be determined by the value of `count.
  • You have multiple lines for the same case. For example, you have 2 accounted for 6 times.
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.