I'm struggling to understand the "return count" portion of this card counting function below:
var count = 0;
function cc(card) {
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;
break;
case 7:
case 8:
case 9:
count+=0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count-= 1;
break;
}
return count + (count > 0 ? " Bet" : " Hold");
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
I know that it is there to return the count, but what is the purpose of the '?' in the statement? I thinking I understand the ":", I'm assuming it means something like "else print 'hold'.