Counting Cards >> What's wrong with my code? I can't see any error here but it's being stuck each time i submit. Please check my code and notice the error

Tell us what’s happening:

Your code so far


function cc(card) {
  // Only change code below this line
  switch(card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count--;
      break;
  }
  
  if (count > 0) {
    return count + "Bet";
  }
  else{
    return count + "Hold";
  }
}

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/counting-cards

Your error is one that I made doing it as well. It doesn’t actually say what to return if the count actually is at 0.

  if (count => 0) {
return count + " Bet";
  } else
  return count + "Hold";

ohhhooo !
I have wasted almost 1 hour for this :open_mouth:
Thank you @rmdawson71

Actually error was here - The tests are expecting a space between the count and the word (Bet or Hold).
Thank you.

1 Like

I was referring to the code posted in the original post. I went the opposite route in solving it, and my code will not pass without the “=” in the if statement.

if (count <= 0) { return count + " Hold"; } else return count + " Bet";. .