Counting Cards (Javascript)

Hello, how are you?

I am doing the counting cards but every time i try to run the test is coming as mistake, could you help me figure out the mistake?

i already he wrote the text many times is always come to the same error saying that the value of return is not bet or hold.

Could you help me understand what i am doing wrong?

thank you very much

down below is way i wrote my code

let 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";
  }
  
  return "Change Me";
  // Only change code above this line
}

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

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like

What does this part do?

1 Like

Thank you, that is my first time posting on the Forum, next time i will do better, Thank you

should return the value of count plus the “String” of “Bet” if the number is bigger than 0

But you have two + signs in there. What does that do?

1 Like

add a number between then as an increment, but now i understand my mistake . Thank you very much for you help :slight_smile:

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