Counting Cards code not running

Tell us what’s happening:
Can someone help me pls, really dont know whats wrong it keep saying

Cards Sequence 7, 8, 9 should return 0 Hold

But if i run the code on vs code it runs perfectly.
Your code so far


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 ++;
            break;
        // case 7:
        // case 8:
        // case 9:
        //     count += 0;
        //     break;
        case 10:
        case 'J':
        case 'Q':
        case 'K':
        case 'A':
            count --;
            break;
    }
    if (count < 0){
      return count + " Hold";
    } else {
      return count + " Bet";
    }
  // 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');

Your browser information:

User Agent is: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0.

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

You have spaces in the lines where you try to increment and decrement.

1 Like

Thanks for finding time to help out, I closed the spaces u pointed out but still giving same Cards Sequence 7, 8, 9 should return 0 Hold. Thanks

Just to let you know that i was able to find solution to the problem, it was from from the if statement, instead of setting count > 0 it was set the other way round. Thanks for ur time once again.