Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created September 22, 2019 14:31
Show Gist options
  • Save NyaGarcia/68dff90e0504c417e1c6aea2f9b186f3 to your computer and use it in GitHub Desktop.
Save NyaGarcia/68dff90e0504c417e1c6aea2f9b186f3 to your computer and use it in GitHub Desktop.
Adding properties conditionally with if statement
const pokemon = {
name: 'Squirtle',
type: 'Water'
};
const abilities = ['Torrent', 'Rain dish'];
const fullPokemon = abilities ? { ...pokemon, abilities } : pokemon;
console.log(fullPokemon);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment