I passed this Card Counting Assistant Lab, however, two of the test criteria for this lab are as follows:
4. After the cards
2,3,4,5, then callingcc(6)should return the string5 Bet.6. After the cards
10,"J","Q","K", then callingcc("A")should return the string-5 Hold.
However, my code is as follows, and when logging in console, it simply returns the initial card plus or minus 1. Why did I pass these tests are am I misunderstanding the instructions? Is it meant to assume as if there were an iteration over the cards/the count?
let count = 0;
let cc = (card) => {
if (card >= 2 && card <= 6) {
count++;
}
else if (card >= 7 && card <= 9) {
count = count;
}
else if (
card === 10 ||
card === 'J' ||
card === 'Q' ||
card === 'K' ||
card === 'A'
) {
count--;
}
if (count > 0) {
return count + ' Bet';
} else if (count <= 0) {
return count + ' Hold';
};
};