Can you please help me with my code , i have tried several times now

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 7:
case 8:
case 9:
count;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;
}
if(count>0){return count="Bet";}
else if(count<=0){return count="Hold";}
return count;
// 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/97.0.4692.71 Safari/537.36 Edg/97.0.1072.62

Challenge: Counting Cards

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.


I don’t think the instructions say to convert the count into a string. It has to stay a number.

so, should i declare another variable to store these string?

Not necessarily. What does the challenge ask you to return?

1 Like

everything it asked me on the left side​:joy::joy:

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 7:
case 8:
case 9:
count;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;
}
var spidey=["Bet","Hold"]
if(count>0){return count=spidey[0];}
else if(count<=0){return count=spidey[1];}
return count;
// 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/97.0.4692.71 Safari/537.36 Edg/97.0.1072.62

Challenge: Counting Cards

Link to the challenge:

This is still overwriting the value of count with a string. That doesn’t fix the problem.

The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative. The current count and the player’s decision ( Bet or Hold ) should be separated by a single space.

Example Outputs: -3 Hold or 5 Bet

Your return values doesn’t look like the examples.

yeah i know that
but what with these number values like “-3” , “5” , “0” prior to Hold , Bet

That’s the count. The thing that you are clobbering and erasing by saving a string into that variable.

oh now i got it
thanks
is it normal to be very dumb at times??:smiling_face_with_tear::smiling_face_with_tear::joy:

Learning how to code takes time. That’s normal.

1 Like

i am really thankful to you
whenever i asked you anything you always asked me to do it first like you really care about my learning.
thanks !..
:smiling_face_with_tear::smiling_face_with_tear:

1 Like

finally got that one right