Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active December 20, 2021 13:44
Show Gist options
  • Save NyaGarcia/b70477b66182512f8e1585ac45bd4ba8 to your computer and use it in GitHub Desktop.
Save NyaGarcia/b70477b66182512f8e1585ac45bd4ba8 to your computer and use it in GitHub Desktop.
Adding an element to an array with the spread operator
const pokemon = ['Squirtle', 'Bulbasur'];
const charmander = 'Charmander';
const cyndaquil = 'Cyndaquil';
const pokedex = [...pokemon, charmander, cyndaquil];
console.log(pokedex); //Result: [ 'Squirtle', 'Bulbasur', 'Charmander', 'Cyndaquil' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment