Basic JavaScript - Counting Cards

Tell us what’s happening:
Describe your issue in detail here.

Everything in my code is correct except for:

case 3, 7, “Q”, 8, “A”:
return “-1 Hold”;
break;

It says that it does not return -1 Hold

My code so far

let count = 0;

function cc(card) {
  // Only change code below this line

switch (card) {
    case 2, 3, 4, 5, 6:
      return "5 Bet";
      break;
    case 7, 8, 9:
      return "0 Hold";
      break;
    case 10, "J", "Q", "K", "A":
      return "-5 Hold";
      break;
    case 3, 7, "Q", 8, "A":
      return "-1 Hold";
      break;
    case 2, "J", 9, 2, 7:
      return "1 Bet";
      break;
    case 2, 2, 10:
      return "1 Bet";
      break;
    case 3, 2, "A", 10, "K":
      return "-1 Hold";
      break;

}

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

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


**Challenge:**  Basic JavaScript - Counting Cards

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/counting-cards

I think you didn’t understand the instructions for this exercise.

You are not supposed to return anything unless you have confirmed the value of the count.

Read the instructions again. Let us know if you don’t understand what you are reading.

(also please post a link to the challenge - edit your post and add it there for our convenience and reference)

You definitely should not try to code answers directly. You need to come up with a process that generates the answers.

Thank you for pointing that out. I did not understand that at first, but I got it after you said about no return.

1 Like

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