Created
November 7, 2019 17:38
-
-
Save NyaGarcia/8ff716e8a1aaaaf8718776842165cb19 to your computer and use it in GitHub Desktop.
Verbose if else if statement
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
function attack(pokemon) { | |
if (pokemon.type === 'water') { | |
useWaterAttack(); | |
} else if (pokemon.type === 'fire') { | |
useFireAttack(); | |
} else if (pokemon.type === 'ice') { | |
useIceAttack(); | |
} else if (pokemon.type === 'electric') { | |
useElectricAttack(); | |
} else { | |
usePsychicAttack(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment