Skip to content

Instantly share code, notes, and snippets.



Last active Aug 5, 2018
What would you like to do?
function getAttackPower(pokemon: Pokemon) {
return pokemon.level * pokemon.attackPower;
function defend(pokemon: Pokemon, damage: number) {
const hp = pokemon.hp - damage;
return Object.assign({}, pokemon, { hp });
function performAttack(attacker: Pokemon, defender: Pokemon) {
const dmg = getAttackPower(attacker);
return {
defender: defend(defender, dmg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment