Counting cards code not working. Need a solution ASAP

This is my code which i wrote for the Counting cards challenge in JS. here i dont see any error but still the code is not working :frowning:

  **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:
    count = count + 1;
    break;
  case 7:
  case 8:
  case 9:
    count = count + 0;
    break;
  case 10:
  case "J":
  case "Q":
  case "K":
  case "A":
    count = count - 1;
    break;

}

var action = "";
if (count < 0){
  action = "Bet";
}else{
  action ="Hold";
}


return count + " "+ action;
// 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/99.0.4844.82 Safari/537.36

Challenge: Counting Cards

Link to the challenge:

the string Bet if the count is positive, or Hold if the count is zero or negative.

Does your code match the condition in the requirements?

You have the condition backwards in your code!

Side note: You should not use var. It is a legacy feature and you should only use const or let.

I’m not sure I understand the “Need a solution ASAP” in your title. Is it a hostage situation? Is there a bomb ticking?

Remember that we are all volunteers giving up our free time to help each other. :wink:

1 Like

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