Last active
June 26, 2018 11:48
-
-
Save Kharouk/b928ac603102ac19ec89be3fbe5d9b0c to your computer and use it in GitHub Desktop.
freeCodeCamp - BlackJack demonstration - Can this be more DRY?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var count = 0; | |
function cc(card) { | |
// Only change code below this line | |
if (card == 1 || card == 2 || card == 3 || card == 4 || card == 5 || card == 6) { | |
count++; | |
} else if (card == 7 || card == 8 || card == 9) { | |
count = count; | |
} else if (card == 10 || card == 'J'|| card == 'Q' || card == 'K' || card == 'A') { | |
count--; | |
} | |
if (count > 0) { | |
return count + " Bet"; | |
} else { | |
return count + " Hold"; | |
} | |
// Only change code above this line | |
} | |
// Add/remove calls to test your function. | |
// Note: Only the last will display | |
cc(2); cc(3); cc(7); cc('K'); cc('A'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment