Can't pass the Card Counting Exercise

Tell us what’s happening:

Please, do your best explaination without giving me the answer. :slight_smile:

Your code so far

var count = 0;

function cc(card) {
// Only change code below this line
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
    count++, " Bet";     
  case 10:
  case 'J':
  case 'Q':
  case 'K':
  case 'A':
    count--, " Hold";
    count, " Hold";

return "Change Me";
// Only change code above this line

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

Your browser information:

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

Challenge: Counting Cards

Link to the challenge:


Take a look at what your function returns. :slight_smile:

Also, this doesn’t seem like valid syntax. :slight_smile:

So I should change the “Change me” to whatever the count-- or count++ and Bet and Hold?

How do you return a number and a string together?

You have two options for that. You can use concatenation:

return variable + " some text here"

Or you can use ES6 template literals:

return `${variable} some text here`

Right. Thank you! Let me give it a try.
So, I’m going to need to have multiple if statements, right?

You could potentially write it with only one if statement.

Remember that return terminates the function - if you keep that in mind, it might help. :slight_smile:

1 Like