So, I encountered a really confusing issue while trying to solve this. The solution for the switch approach looks like this:
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
That’s fine, but, while looking through the hints and other peoples’ solutions, I saw someone formatting their switch like this:
switch (card) {
case 2,3,4,5,6:
count++;
break;
This is where my problem is; When using this person’s format, I found that count would never increase. However, formatting cases 10, J, Q, K, and A the same way would decrease count properly (I tested this in Chrome’s console). Could anyone explain this one to me? Is there an issue with laying out cases horizontally?
That would explain why case 2,3,4,5,6: would never actually add to the count. But, doing the same thing for case 10, ‘J’, ‘Q’, ‘K’, ‘A’: actually worked (count-- would work). That’s what had me stumped for quite a while.
Then I’m even more confused than before. xD Well, I’m past it already, but I wanted to try and get some understanding on how that actually worked (or didn’t work in this case). Appreciate the quick response.