Javascript card counting

Tell us what’s happening:

here is my code, can anyone tell me what’s wrong with it?

Your code so far


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=count+1; break;
 case 10:
 case 'J':
 case 'Q':
 case 'K':
 case 'A': count=count-1; break;
  
}
return count;

 // Only change code above this line
}

cc(7); cc(8); cc(9); cc(5); cc(6);
if (count <=0) {console.log( count+" Hold");}
else  console.log(count+" Bet");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.

Challenge: Counting Cards

Link to the challenge:

Hello and welcome to the freeCodeCamp community~!

These two lines are outside of your function, and thus do not appear to be doing anything. You want them inside the function, and instead of console.log() the values you want to return them. :slight_smile:

1 Like

thank you so much, it worked

1 Like