Card Counting Challenge - how is this code wrong?

Can anyone tell me what is wrong with my code? When I test it it fails every test, but it looks essentially the same as lootster’s.

var count = 0;

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

    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
    var count--;


    if (count > 0) {
      return count + "Bet";

    else {
      return count + " Hold";

  // Only change code above this line

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

@stevetaul It is best to start a new topic about a challenge if the problem you are having is specific to you and unrelated to the OP’s question(s). I have moved your question to this new thread.

Also, I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


That is not the right way to increase the variable. Here you are declaring the variable again by using var. You just want to increase count.

1 Like

Thanks! It worked like a charm

Glad it’s solved! Nice