Counting Cards Challenge 2

Counting Cards Challenge 2
0.0 0

#1

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:


#2

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”


#3

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
}


#4

If I had two strings each containing a word and wanted to concatenate the two strings together with a space in the middle, I would do the following:

var string1 = "Good";
var string2 = "Morning";
var concatenated = string1 + " " + string2;

See if the above example helps with how to add the extra space you need to complete this challenge.


#5

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