Skip to content

Instantly share code, notes, and snippets.

@fxcosta
Last active April 24, 2017 02:40
Show Gist options
  • Save fxcosta/1976ac29748aee7fecc2215f16bbbb1a to your computer and use it in GitHub Desktop.
Save fxcosta/1976ac29748aee7fecc2215f16bbbb1a to your computer and use it in GitHub Desktop.
let warrior = {
hp: 100,
strength: 20,
attack: function(target) {
target.hp -= this.strength;
}
}
let enemy = {
hp: 100,
strength: 12,
attack: function(target) {
target.hp -= this.strength;
}
}
warrior.attack(enemy);
console.log(enemy.hp); // output: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment