What's wrong with my counting card code

var count = 0;

function cc(card) {

  // Only change code below this line


  case 2:

  case 3:

  case 4:

  case 5:

  case 6:



  case 10:

  case 'J':

  case 'Q':

  case 'k':

  case 'A':




if(count > 0) {

    return count + " Bet";

  } else {

    return count + " Hold";



  // Only change code above this line


cc(2); cc(3); cc(7); cc('K'); cc('A');

To decrement or decrease a variable by one you can use the - - operator on the variable. Therefore, to decrement global count variable , use count- -

I assume, you have it as count-

You’ve a spelling mistake here:

case 'k':

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thanks man, your observation actually gave out the solution.

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