This is my code it's not working

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

let count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
  count++;
  break;
case 10:
case "J":
case "Q":
case "K":
case "A":
  count--;
  break;

}
if (count > 0){
return count + "Bet";
} else {
return count + "Hold";
}
return "Change Me";
// 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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Counting Cards

Link to the challenge:

HI @clash28ofclans13 !

I would suggest adding a console.log to see the issue more clearly.
You can add it at the bottom of your code here

console.log(cc(2))
cc(2); cc(3); cc(7); cc('K'); cc('A');

Also, this isn’t doing anything so you can delete it

I tried this this is result : Cards Sequence 2, 3, 4, 5, 6 should return the string

5 Bet

Cards Sequence 7, 8, 9 should return the string

0 Hold

Cards Sequence 10, J, Q, K, A should return the string

-5 Hold

Cards Sequence 3, 7, Q, 8, A should return the string

-1 Hold

Cards Sequence 2, J, 9, 2, 7 should return the string

1 Bet

Cards Sequence 2, 2, 10 should return the string

1 Bet

Cards Sequence 3, 2, A, 10, K should return the string

-1 Hold

// tests completed // console output 1Bet 1Bet

Read this more carefully. This is your output.

Now read the correct answer more carefully

It is a small detail but important.
Hopefully you can spot it :grinning:

You need to make changes here

and here

to fix your spacing issue.

Hope that helps

2 Likes

Thanks for help jwilkins i was trying to fix it but it was not working but because of your help it is now working. Thank you very much :slight_smile:

2 Likes