JavaScript: Card Count

It’s the little accomplishments without assistance that keep me moving forward. Today’s real challenge on Free Code Camp’s basic JavaScript segment was a simple card count that gave me the chance to practice switch/case and if/else logic:

var count = 0;

// increment/decrement count based on card 
function cc(card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
      count = count;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
  // return count based on incrementation
  if(count > 0){
    return count + " Bet";
    return count + " Hold";

// test results
cc(2); cc(3); cc(7); cc('K'); cc('A');

This looks like a potential code pen project!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s