Created
September 23, 2019 15:41
-
-
Save NyaGarcia/d284de4a5c37a20cc0bbb98713d0c8c3 to your computer and use it in GitHub Desktop.
An example showcasing the use of the rest parameter
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 printPokemon(name, type, ...abilities) { | |
console.log( | |
`${name} is a ${type} type Pokemon. ${name}'s abilities are: ${abilities.join( | |
', ' | |
)}` | |
); | |
} | |
printPokemon('Squirtle', 'Water', 'Torrent'); | |
//Squirtle is a Water type Pokemon. Squirtle's abilities are: Torrent | |
printPokemon('Squirtle', 'Water', 'Torrent', 'Rain Dish'); | |
//Squirtle is a Water type Pokemon. Squirtle's abilities are: Torrent, Rain Dish | |
printPokemon('Squirtle', 'Water', 'Torrent', 'Rain Dish', 'Surf', 'Secret Ability', 'And so on...'); | |
//Squirtle is a Water type Pokemon. Squirtle's abilities are: Torrent, Rain Dish, Surf, Secret Ability, And so on... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment