Counting Cards - an error

Hi everyone,

Can someone please tell me what’s wrong with my code?! Thanks in advance!

var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    count ++;
    return count + " Bet";
    break;

    case 7:
    case 8:
    case 9:
    return count + " Hold";
    break;

    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
    count --;
    return count + " Hold";
    break;
  }
  
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

it seems your code is sintatically correct. I can’t help you if you don’t provide the requirements.

.

.

.

.

.

.

.

Well, luckily for you I know the requirments of the challenge…

your returned value is based only on the value of the card, but you are asked to determine the returned valued based on the value of count

Thanks for your reply! It is for this challenge, but doesn’t pass it:

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/counting-cards

Don’t know why!

Your code to count the cards is correct, but your logic to hold/bet is the issue. To follow up on what @ilenia wrote. The purpose of the code is to first figure out what the total count is, then to make a hold/bet decision based on that count. Try breaking up your answer into two parts. Figure out the count, and then write some logic (I would use an If statement here) to get your pass/hold designation. Finally, return both parts in one statement per the requirements of the exercise. GL

Thank you both @Aaronms and @ilenia. I think I figured out what’s the problem with the logic.