Skip to content

Instantly share code, notes, and snippets.

@jackfranklin
Created July 14, 2013 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackfranklin/5995655 to your computer and use it in GitHub Desktop.
Save jackfranklin/5995655 to your computer and use it in GitHub Desktop.
var Player = function(name) {
this.name = name;
this.hand = [];
this.handTotal = 0;
}
Player.prototype.calculateHandTotal = function() {
this.handTotal = 0;
for (var i = 0; i < this.hand.length; i++) {
this.handTotal += (this.hand[i].value > 10) ? 10 : this.hand[i].value;
}
};
Player.prototype.isBust = function() {
this.calculateHandTotal();
return (this.handTotal > 21);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment