Function isn't decrimenting correctly

Tell us what’s happening:
Describe your issue in detail here.
I’m trying to count cards using this function but for some reason my count is not adding and subtracting correctly. Any advice?

  **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:
    return count += 1;
  case 10:
  case 'J':
  case 'Q':
  case 'K':
  case 'A':
    return count -= 1;

if(count > 0) {
  return count + " " + "Bet"; 
} else {
  return count + " " + "Hold";
// 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 (X11; CrOS x86_64 14150.64.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.104 Safari/537.36

Challenge: Counting Cards

Link to the challenge:

Hi @websterdarrin0 !

The issue is these return statements here

You need to get rid of the return keywords because a return exits the function.

Right now you are not even getting to this part right here

Once you get rid of those two returns inside the switch statement then the test will pass.

Thank you for catching that!

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