counting cards

Solutions on MaxInterview for counting cards by the best coders in the world

showing results for - "counting cards"
Riccardo
07 Jan 2019
1var count = 0;
2
3function cc(card) {
4switch(card){
5  case 2:
6  case 3:
7  case 4:
8  case 5:
9  case 6:
10  count++;
11  break;
12  case 10:
13  case 'J':
14  case 'Q':
15  case 'K':
16  case 'A':
17  count--;
18  break;
19}
20  if(count > 0){
21  return count + " Bet";
22  }else{
23  return count + " Hold"
24  }
25}
26
27cc(2); cc(3); cc(7); cc('K'); cc('A');
28console.log(cc(2)); //Check your code with console log.