const pokemon = {
  name: 'Squirtle',
  type: 'Water'
}

let abilities = [];

const addAbilities = pokemon => ({
  ...pokemon,
  ...(abilities.length && { abilities })
});

console.log(addAbilities(pokemon));

abilities = ['Torrent', 'Rain Dish'];

console.log(addAbilities(pokemon));

// {name: "Squirtle", type: "Water"}
// {name: "Squirtle", type: "Water", abilities: Array[2]}