I’ve been working on this for the past hour and still can’t figure out what I’m missing. The answer seems to be write whenever I put in the cards but FCC keeps saying that there is an error
My code so far
var count = 0;
function cc(card) {
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
return count++;
break;
case 7:
case 8:
case 9:
return count = count;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
return count--;
break;
}
var holdBet = "Hold";
if (count > 0) {
holdBet = "Bet";
}
return count + " " + holdBet;
}
cc(2); cc(3); cc(4); cc(5); cc(6);
console.log(cc());
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36.
I also changed the output to “return count + holdBet;” and then added a space before the holdBet variable definition to make it " Hold" and " Bet" and still no dice…
Hi there thanks for sending this my way. Its a bit confusing because in the FCC lesson, the examples all have multiple breaks and return statements which is why I wrote my code the way I did… But the link you sent seems to suggest that switches shouldn’t be written this way.
hi so should I remove the return statements in the function so that the if statement can be executed? If I do that then how do I tell the function what to output based on the case?