# Can u please send me help in counting card

**URL:** <https://forum.freecodecamp.org/t/can-u-please-send-me-help-in-counting-card/170174>\
**Category:** General\
**Created:** [January 22, 2018, 7:11am UTC](https://forum.freecodecamp.org/t/can-u-please-send-me-help-in-counting-card/170174 "2018-01-22T07:11:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![payal](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@payal](https://forum.freecodecamp.org/u/payal)\
**Post date:** [January 22, 2018, 7:11am UTC](https://forum.freecodecamp.org/t/can-u-please-send-me-help-in-counting-card/170174/1 "2018-01-22T07:11:01Z")

</div>

**Tell us what’s happening:**

**Your code so far**

```auto
var count = 0;

function cc(card) {
  // Only change code below this line
  
  
  var val;
  var finalcount=0;
  for (var i = 0; i < arguments.length; i++) {
   
    val= Number(arguments[i]);
  
  
  if(val==2 || val==3 || val==4 || val==5 || val==6 )
    {
      count=1;
    }
  else if(val==10 || val=='J'|| val=='Q' || val=='K' || val=='A')
    {
      count= -1;
    }
  else 
    {
      count=0;
    }
    
    if(count>0)
      {
       finalcount += count;
 
      }
    else
      {
        finalcount -= count;
      }
    
    
  
  
  } 
  if (finalcount > 0)
        {
            
          return finalcount +" " + "Bet";
        }
        else
         {
             
         return finalcount +" " + "Hold";
         }
  
  
  //return "Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
//cc(2); cc(3); cc(7); cc('K'); cc('A');
//cc(2,3,4,5,6);
cc(10,'J','Q','K','A');

```

**Your browser information:**

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36`.

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/counting-cards](https://www.freecodecamp.org/challenges/counting-cards)

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [January 22, 2018, 8:00am UTC](https://forum.freecodecamp.org/t/can-u-please-send-me-help-in-counting-card/170174/2 "2018-01-22T08:00:37Z")

</div>

I don’t think you can put all of the card inputs in a single call to `cc`. You have to call them one by one (ala the first commented code at the bottom). This makes the `finalcount` variable unnecessary, since you’ll be dealing with the global `count` variable for every call.

---

<div class="post-metadata">

**Author:** ![payal](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@payal](https://forum.freecodecamp.org/u/payal)\
**Post date:** [January 22, 2018, 1:37pm UTC](https://forum.freecodecamp.org/t/can-u-please-send-me-help-in-counting-card/170174/3 "2018-01-22T13:37:32Z")

</div>

I did it first .but that code did not work .thats why I put all the things

---

<div class="post-metadata">

**Author:** ![payal](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@payal](https://forum.freecodecamp.org/u/payal)\
**Post date:** [January 22, 2018, 3:01pm UTC](https://forum.freecodecamp.org/t/can-u-please-send-me-help-in-counting-card/170174/4 "2018-01-22T15:01:18Z")

</div>

**Tell us what’s happening:**

**Your code so far**

```auto

function cc(card) {
  // Only change code below this line
  var count ;
  
  if(card==2 || card==3 || card==4 || card==5 || card==6 )
    {
      count=1;
     

    }
  else if(card==10 || card=='J'|| card=='Q' || card=='K' || card=='A')
    {
      count = -1;
          
    }
  else 
    {
      count=0;
    }
  
  if (count >0)
    {
      return count +" "+ "Bet" ;
    }
  else
    {
      return count +" "+ "Hold" ;
    }

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

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

```

**Your browser information:**

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36`.

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/counting-cards](https://www.freecodecamp.org/challenges/counting-cards)

---

<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 17, 2021, 8:29pm UTC](https://forum.freecodecamp.org/t/can-u-please-send-me-help-in-counting-card/170174/5 "2021-01-17T20:29:41Z")

</div>

Closed on January 17, 2021, 8:29pm UTC


