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) {
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
count = count;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;
}
// return count based on incrementation
if(count > 0){
return count + " Bet";
}else{
return count + " Hold";
}
}
// test results
cc(2); cc(3); cc(7); cc('K'); cc('A');
This looks like a potential code pen project!