Counting Cards Challenge 2

Hello campers below is the code i wrote but i cant seem to pass the challenge, what could be wrong with the code?

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 10:
      case "J":
      case "Q":
      case "K":
      case "A":
      count --;
      break;
  }
      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(2); cc(3); cc(7); cc('K'); cc('A');

Your browser information:

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

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

Check the instructions again. Your code got the output cases mixed up.

Also check your output strings. The tests require that there is a space between the count and “Bet” or “Hold”

1 Like

Thanks but how do i get this --> “The current count and the player’s decision (“Bet” or “Hold”) should be separated by a single space” My code returns 0Hold. There’s no space. See below
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 10:
case “J”:
case “Q”:
case “K”:
case “A”:
count–;
break;
}
if (count > 0){
return count + “Bet”;
} else {
return count + “Hold”;
}

// Only change code above this line
}

Great thanks i see it now, the challenge is passed.