Card-counting challenge


I’ve managed the first three card sequences (2 3 4 5 6, 7 8 9 and 10 J Q K A) without much ado but the subsequent sequences have proven more challenging. Neither a set of if/else if/else statements nor a switch statement wouldn’t work on those.

Here’s my code:

Thanks in advance for any help.

Before you continue trying to solve. Where are you updating the variable count like it tells you?

1 Like

I’m sorry, but I don’t think you fully understand what this challenge want you to do.
For case 2, 3, 4, 5, 6, it wants you to add 1 to the global variable count, and for 10 ‘j’ ‘q’ ‘k’ ‘a’, you need to -1 in count

1 Like

And then, you need to check the count and return count and “bet” if count > 0 else return hold if count <= 0;

1 Like

check this link

1 Like

Hi there.

I checked the link and compared that person’s code with my own. It seems I’ve over-thought this. I didn’t use count. My mistake. There was no need to include cases 7-9 in my switch statement because the count wasn’t supposed to change in those cases. My original if statement seems to have over-complicated the task, perhaps through excessive nesting (six layers). The other person’s if statement used a lot less code than mine. The return statements weren’t supposed to have a number, just the count variable + " Bet" if the count was incremented or " Hold" if the count was decremented.

Thank you for your help. I’ve ticked Solution under your last post.