Basic JavaScript - Counting Cards

Tell us what’s happening:
Describe your issue in detail here.
The code refuses to accept anything except if (count <= 0){then return etc}
Also I am pretty sure it would not accept the video solution as I have not been able to get that one to show anything decent on screen.
I have solved it but it is awkward finding correct responses fail. I only was rejected on the 10,“J”,“Q”,“K”,“A” = -5 despite having count – or count -= 1 for the above reason which makes it hard to believe more of the teaching

   **Your code so far**
let count = 0;

function cc(card) {
 // Only change code below this line
let answer;
 case 2:
 case 3:
 case 4:
 case 5:
 case 6:
 case 7:
 case 8:
 case 9:
 case 10:
 case 'J':
 case 'Q':
 case 'K':
 case 'A':
 count = count-1;  

if (count <=0 ){
  return count + " Hold" ;
 return count + " Bet";

/*After you’ve counted the cards, use an if statement to check the value of count. Also, make sure your return has a space between the number and the string.*/
 // 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/104.0.5112.81 Safari/537.36 Edg/104.0.1293.54

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

when i try to run your code, all of the tests seem to pass for me. Try running this on another browser if this problem continues.

This could be a problem in some browser instances:

count = count-1;

Try to see what the devtools logs look like
Why not to use the same way you did with count++?

I am also stuck here. I think you need to add the return function to scale through

I doubt it. That is a fundamental piece of Javascript syntax.

We can’t comment on code that you think should pass unless you show us the code. There are many ways to write a valid solution.

I had alternative manners of saying this which seemed to be the reason the code didn’t pass. If I recall like using || maybe &&, an else statement. I think these others would have worked too is what I mean yet were rejected.

thanks, I suppose it is very easy for me to mix up global and local variables at the moment., for instance.

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