# Card Counting help (not the solution but a nudge in the right direction please) \[SOLVED\]

**URL:** <https://forum.freecodecamp.org/t/card-counting-help-not-the-solution-but-a-nudge-in-the-right-direction-please-solved/81041>\
**Category:** General\
**Created:** [January 27, 2017, 4:45am UTC](https://forum.freecodecamp.org/t/card-counting-help-not-the-solution-but-a-nudge-in-the-right-direction-please-solved/81041 "2017-01-27T04:45:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danthecardman](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/danthecardman/32/36049_2.png) [@danthecardman](https://forum.freecodecamp.org/u/danthecardman)\
**Post date:** [January 27, 2017, 4:45am UTC](https://forum.freecodecamp.org/t/card-counting-help-not-the-solution-but-a-nudge-in-the-right-direction-please-solved/81041/1 "2017-01-27T04:45:12Z")

</div>

**I’ve been at this for several hours; and I’m stuck.**  
[https://gist.github.com/danthecardman/90a75d16b79b8278dc5a3761ff53bad3.js](https://gist.github.com/danthecardman/90a75d16b79b8278dc5a3761ff53bad3.js)

In my code I passed 3 of the 7 requirements. What I’m not grasping is how to code up a switch statement for when a specific card sequence is required to pass the exercise.

Here are the requirements (the first 3 I coded properly):  
Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"  
Cards Sequence 7, 8, 9 should return "0 Hold"  
Cards Sequence 10, J, Q, K, A should return "-5 Hold"  
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"  
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"  
Cards Sequence 2, 2, 10 should return "1 Bet"  
Cards Sequence 3, 2, A, 10, K should return “-1 Hold”

```
var count = 0;

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

  
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      card= "5 Bet";
      count +=1;
      break;
    case 7:
    case 8:
    case 9:
      card="0 Hold";
// count +=1;
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      card="-5 Hold";
      count -=1;
      break;
      
   // case 3,7,'Q',8,'A':
    case 3:
    case 7:
    case 'Q':
    case 8:
    case 'A':
      card= "-1 Hold";
      count -=1;
      break;
   // case 2,'J',9,2,7:
    case 2:
    case 'J':
    case 9:
    case 2:
    case 7:
      card= "1 Bet"; 
      count +=1;
      break;
    //case 2,2,10:
    case 2:
    case 2:
    case 10:
      card= "1 Bet";
      count +=1;
      break;
    //case 3,2,'A',10,'K':
    case 3:
    case 2:
    case 'A':
    case 10:
    case 'K':
      card= "-1 Hold";
      count -=1;
     break;
  }
  
  return card;//"Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
//cc(3); cc(7); cc('Q'); cc(8); cc('A');
cc(2); cc('J'); cc(9); cc(2); cc(7);

gist:90a75d16b79b8278dc5a3761ff53bad3
```

---

<div class="post-metadata">

**Author:** ![coles303](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@coles303](https://forum.freecodecamp.org/u/coles303)\
**Post date:** [January 27, 2017, 5:48am UTC](https://forum.freecodecamp.org/t/card-counting-help-not-the-solution-but-a-nudge-in-the-right-direction-please-solved/81041/2 "2017-01-27T05:48:24Z")

</div>

Why are you adjusting card in your switch statement? Your first 3 appear to be correct, they’re not really as card simply holds the value this challenge expects as it met the case in the switch statement.

The extra cases after // case 3,7,‘Q’,8,‘A’ are not needed & I’m not quite sure what they’re meant to be about.

It’d be easier to evaluate the value of count after all arguments have been passed with an if statement & then return count + a string to say to hold or bet. Say if count is greater than 0, you’d like to return count + a string

---

<div class="post-metadata">

**Author:** ![danthecardman](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/danthecardman/32/36049_2.png) [@danthecardman](https://forum.freecodecamp.org/u/danthecardman)\
**Post date:** [January 28, 2017, 6:56am UTC](https://forum.freecodecamp.org/t/card-counting-help-not-the-solution-but-a-nudge-in-the-right-direction-please-solved/81041/3 "2017-01-28T06:56:12Z")

</div>

> [@coles303](#):
>
> It’d be easier to evaluate the value of count after all arguments have been passed with an if statement & then return count + a string to say to hold or bet. Say if count is greater than 0, you’d like to return count + a string

thank you @coles303 your suggestion helped me look at it completely different. I finally got it working

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:11pm UTC](https://forum.freecodecamp.org/t/card-counting-help-not-the-solution-but-a-nudge-in-the-right-direction-please-solved/81041/4 "2021-01-16T17:11:56Z")

</div>


