Tell us what’s happening:
So I’m trying to figure out how to get the log to stop printing ’ bet/hold’ after EACH card. ‘break’ should make it move to the next card, but then how does it ever get to the if/else statement that prints the card count and bet/hold recommendation? Each iteration of the function includes the if/else statement that prints the count and recommendation - it makes sense that it would print something after EACH card. How would you get the function to perform only half the function until the very last use?
(I’m probably overthinking this.)
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;
}
if (count > 0) {
console.log(count + " Bet");
} else {
console.log(count + " Hold");
}
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
.
Challenge: Counting Cards
Link to the challenge: