Counting Cards video lesson steering me wrong?

This seems to be correct in my understanding of the video lesson. But it does not seem to be returning what the problem is asking for. Any thoughts?

Several times in the last few tutorials It seems like I have to clear the code and re-enter my work the same way before it accepts it… is the system being buggy or am I missing something in my code?

Thanks

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++;
    break;
  case "10":
  case "J":
  case "Q":
  case "K":
  case "A":
    count--;
    break;
}
var holdbet = " Hold";
if (count > 0) {
  holdbet = " Bet";
}
return count + holdbet;
// Only change code above this line
}

cc(10); cc(6); cc("J"); cc('K'); cc(4);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36.

Challenge: Counting Cards

Link to the challenge:

Hi @dmay,

Compare how number 10 is passed in the function call and how it is defined in switch case. Former is integer and latter is string. That’s why it is failing the comparison. Changing “10” to 10 in switch case will resolve the issue

Thanks you so much Sunithack1! Worked Great!

I am a novice and those little things can be very confusing. Great explanation. I really appreciate your help!

D