# Counting Card Problem

I dont know why my solution is not working, could someone take a look?

Thanks!

Here is my solution :
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 += 1;
break;
case 7:
case 8:
case 9:
count = 0;
break
case 10:
case “J”:
case “Q”:
case “K”:
case “A”:
count -=1 ;
break
}
if (count > 0){
return count + “Bet”
}else{
return count + “Hold”
};
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Do you really want to reset count to 0 if the card is a 7, 8, or 9? Do you really need to do anything with count if the card is a 7, 8, or 9? Does your select statement even need cases for 7, 8, or 9?

Also, make sure your return statement returns a string like “5 Bet” and not “5Bet”.

Hey Randell,

I removed the 7,8,9 cases and it worked.
Although i dont understand why it wouldnt work with count = 0. Wouldnt it just add 0 to the count?

Thanks!

There is a difference between adding 0 to count and setting the value of count to 0.

``````var count = 10;
count += 0; // count is still 10

count = 0; // count is now 0
``````
1 Like

I understand now!

Thanks!