# Counting Cards - What am I doing wrong here?

**URL:** <https://forum.freecodecamp.org/t/counting-cards-what-am-i-doing-wrong-here/367331>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [April 2, 2020, 11:16pm UTC](https://forum.freecodecamp.org/t/counting-cards-what-am-i-doing-wrong-here/367331 "2020-04-02T23:16:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vcfratts](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/vcfratts/32/140583_2.png) [@vcfratts](https://forum.freecodecamp.org/u/vcfratts)\
**Post date:** [April 2, 2020, 11:16pm UTC](https://forum.freecodecamp.org/t/counting-cards-what-am-i-doing-wrong-here/367331/1 "2020-04-02T23:16:30Z")

</div>

I honestly can’t figure out what I am doing wrong???

I gave up and looked at the solution code and honenstly… I still don’t see the issue with what I wrote??? Can anybody tell me what I’ve missed???

**Your code so far**

```js

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=count+1)
  break;
case 7:
case 8:
case 9:
  return (count)
  break;
case 10:
case "J":
case "Q":
case "K":
case "A":
  return (count=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 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0`.

**Challenge:** Counting Cards

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/counting-cards)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [April 3, 2020, 2:43pm UTC](https://forum.freecodecamp.org/t/counting-cards-what-am-i-doing-wrong-here/367331/3 "2020-04-03T14:43:15Z")

</div>

> [@vcfratts](#):
>
> return (count=count+1)

A few things:

- Remember that as soon as a `return` statement is hit, the function is done. Any code after a `return` statement is “unreachable”. Your if/else block for “Bet” and “Hold” will never run.
- This return statement (and the third one) will return the result of the _assignment_. It will not return the value of `count`.

---

<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:** [June 1, 2021, 12:58pm UTC](https://forum.freecodecamp.org/t/counting-cards-what-am-i-doing-wrong-here/367331/4 "2021-06-01T12:58:57Z")

</div>

Closed on June 1, 2021, 12:58pm UTC


