ndburrus

Card Counting @m4sterbunny

Aug 10th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. // Card Counting
  2. // @m4sterbunny
  3. // Card Counting, can I use Switch for this? sure! (or an if/else statement)
  4.  
  5.  
  6. var count = 0;
  7. function cc(card) {
  8. // Only change code below this line
  9.  
  10. switch (count) {
  11. case 2:
  12. case 3:
  13. case 4:
  14. case 5:
  15. case 6:
  16. count += count; <!-- ok, here. is this what we want? the count needs to increment by one (1)
  17. if any of these cases are met. -->
  18. break;
  19. case 7:
  20. case 8:
  21. case 9:
  22. count = count +0; <!-- don't really need a count statement, as there is no change for these cases. -->
  23. break;
  24. case 10:
  25. case "J":
  26. case "Q":
  27. case "K":
  28. case "A":
  29. count -= count; <!-- again, we need to ensure we make the correct change for these cases. for these,
  30. the count should decrease by one (1).
  31. break;
  32. }
  33. if (count > 0) {
  34. return ("count" " Bet");
  35. }
  36. else if (count <= 0) {
  37. return ["count" " Hold"];
  38. }
  39. // Only change code above this line
  40. }
  41. // Add/remove calls to test your function.
  42. // Note: Only the last will display
  43. cc(2); cc(3); cc(7); cc('K'); cc('A');
Add Comment
Please, Sign In to add comment