Counting Cards ( Missing one card sequence)

Hi guys, in this exercise, I am missing one card sequence, I tried and change all the possible values and still that It does not return the string value:

let count = 0;

function cc(card) {
  // Only change code below this line
switch (card) {
  case 9:
    return "0 Hold";
    break;
  case 'A':
    return "-5 Hold";
    break;
  case 6:
    return "5 Bet";
    break;
  case 10:
    return "1 Bet";
    break;
  case 7:
    return "1 Bet";
    break;
  case 'K':
    return "-1 Hold";
    break;
  case 'Q':
    return "-1 Hold";
    break;
}
  // Only change code above this line
}

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

Console shows:

// running tests
Cards Sequence 3, 7, Q, 8, A should return the string -1 Hold
// tests completed

I tried to change the last ‘Q’ for all the numbers that it should return the string “-1 Hold” and It does not work. Any ideas?

This saying that every single time you see a 9 you must want the result 0 Hold. That’s not consistent with the instructions.

(Note: easier for me to quote the instructions if you provide a link to the challenge)

You will write a card counting function. It will receive a card parameter, which can be a number or a string, and increment or decrement the global count variable according to the card’s value (see table). The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative. The current count and the player’s decision (Bet or Hold) should be separated by a single space.

Lets break that into smaller chunks of text

  1. You will write a card counting function.

  2. It will receive a card parameter, which can be a number or a string

  3. increment or decrement the global count variable according to the card’s value (see table)

  4. then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative.

You are mixing together 3) and 4), but they really need to be done separately in your function.

1 Like

That means my whole function is wrong? Or Should I just change the values?

Because all the remaining strings from the exercise said are good.

Are you doing this in your function? It doesn’t look it to me. You need to do part 3 first before you do part 4.

1 Like

No, I do not think so. So I should first do number 3. I guess with:

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/multiple-identical-options-in-switch-statements

I can figure it out the step n3 :smiley:

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