Basic JavaScript - Counting Cards

Tell us what’s happening:

Describe your issue in detail here.
what’s wrong with my code that it is not acceptable?

Your code so far

let count = 0;

function cc(card) {
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;
}
  let holdbet = 'hold';
  if (count > 0) {
  holdbet = 'bet'
  }
  return count + " " + holdbet;
}

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/119.0.0.0 Safari/537.36

Challenge Information:

Basic JavaScript - Counting Cards

Hello, the logic here is an if/else statement and two returns: if the condition is met return
“bet” else return “hold”. Remember this is probably only one solution and you could use the let keyword but it would have to be coded differently with logical operators.

Hi there and welcome to our community!

The only issue with your code is that you are not returning exactly the required strings. The string should be either ‘Hold’ or ‘Bet’.

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