Last active
April 24, 2017 02:40
-
-
Save fxcosta/1976ac29748aee7fecc2215f16bbbb1a to your computer and use it in GitHub Desktop.
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
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