# Problem with counting card challenge?

**URL:** <https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [September 7, 2021, 11:20am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899 "2021-09-07T11:20:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsurwase](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hsurwase/32/206983_2.png) [@hsurwase](https://forum.freecodecamp.org/u/hsurwase)\
**Post date:** [September 7, 2021, 11:20am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/1 "2021-09-07T11:20:14Z")

</div>

here is my code, i have not understand what was did i wrong here!  
please help me out from this one.  
with explanation.

```auto
var count = 0;
function cc(card) {
// Only change code below this line

switch(card){
  case 2:
 case 3:
  case 4:
 case 5:
case 6:
count += 1;
 break;
 case 7:
 case 8:
 case 9:
  count += 0;
break;
case 10:
case "J":
case "Q":
 case "K":
 case "A":
 count -= 1;
  break;
 }

   return count + (count > 0 ? "Bet" : "Hold");
// Only change code above this line
}

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

```

> **[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:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [September 7, 2021, 11:22am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/2 "2021-09-07T11:22:24Z")

</div>

I’ve edited your post 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.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [September 7, 2021, 11:25am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/3 "2021-09-07T11:25:46Z")

</div>

Hi @hsurwase !

I edited your post to include the challenge link.

> [@hsurwase](#):
>
> i have not understand what was did i wrong here!

You have a spacing issue.

Add this ` console.log(count + (count > 0 ? "Bet" : "Hold"))` right above the return statement and you will see what I mean.

---

<div class="post-metadata">

**Author:** ![hsurwase](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hsurwase/32/206983_2.png) [@hsurwase](https://forum.freecodecamp.org/u/hsurwase)\
**Post date:** [September 7, 2021, 11:39am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/4 "2021-09-07T11:39:27Z")

</div>

Hi @jwilkins.oboe  
I understand, I need to put a space between the count and bet.  
I’m trying to space between them but fail

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [September 7, 2021, 11:40am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/5 "2021-09-07T11:40:29Z")

</div>

Did you also add a space between count and hold?

---

<div class="post-metadata">

**Author:** ![hsurwase](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hsurwase/32/206983_2.png) [@hsurwase](https://forum.freecodecamp.org/u/hsurwase)\
**Post date:** [September 7, 2021, 11:46am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/6 "2021-09-07T11:46:18Z")

</div>

No,

````auto
console.log((count + (count > 0 ? " Bet " : " Hold ")))
```Preformatted text
````

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [September 7, 2021, 11:47am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/7 "2021-09-07T11:47:45Z")

</div>

You don’t need to add a space at the end of Bet or Hold.

You just need to add a space before the words.

Also, make sure you are adding those space to the return statement too.

---

<div class="post-metadata">

**Author:** ![hsurwase](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hsurwase/32/206983_2.png) [@hsurwase](https://forum.freecodecamp.org/u/hsurwase)\
**Post date:** [September 7, 2021, 11:50am UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/8 "2021-09-07T11:50:03Z")

</div>

Yes, it worked…  
thanks you…

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [March 8, 2022, 11:50pm UTC](https://forum.freecodecamp.org/t/problem-with-counting-card-challenge/476899/9 "2022-03-08T23:50:43Z")

</div>

Closed on March 8, 2022, 11:50pm UTC

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