Basic JavaScript - Counting Cards

Tell us what’s happening:

Why I am not able to pass case

 case "J":
 case "Q":
 case "K":
 case "A":

It seems the code is fine but it is not passing, I tried to check with console log but it seem to be right output.

Your code so far

let count = 0;

function cc(card) {
  // Only change code below this line
// if(card => 2 || card <= 6){
//   count +=1;
// }
// console.log(count + " Hold");
//   return count + " Hold";
  case 2: 
  case 3:
  case 4:
  case 5:
  case 6:
    count ++;
  case 7:
  case 8:
  case 9:
    count == 0;
  case 10:
  case "J":
  case "Q":
  case "K":
  case "A":
    count -=5
if(count > 1){
  return count +" Bet";
}else if(count == 0){
  return count + " Hold";
}else if(count == -5){
  console.log(count+" Hold")
  return count +" Hold";

  // 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/ Safari/537.36

Challenge Information:

Basic JavaScript - Counting Cards

Why are you subtracting 5 from count when a high card is played?

1 Like

Hello @mahassan !

Perhaps the following from the freeCodeCamp youtube channel will help you better understand this lesson and how to solve it.

I found the lesson very challenging. But, I never thought to check it out on the youtube channel. lol

Happy coding!

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