title: Javascript push a promise into an array
body: <p>I'm trying to create an array of promises and call them with <code>Promise.all</code>.</p>
  
  <p>I'm having trouble with correctly pushing the functions into the array, it seems they are being called instead of inserted and wait for <code>Promise.all()</code>.</p>
  
  <pre><code>function findSpecialAbility(players, gameId, message) {
    return new Promise(function(resolve, reject) {
      let playersWithSpecials = _.reject(players, function(p) {
        return p.role === 'alphaWolf' ||
          p.role === 'betaWolf' ||
          p.role === 'villager' ||
          p.role === 'alchemist' ||
          p.targetId === 0 ||
          p.abilityUsed === true;
      });
      if (playersWithSpecials.length === 0) {
        resolve();
      } else {
        let specialsToUse = [];
        for (let i = 0, j = playersWithSpecials.length; i &lt; j; i++) {
          specialsToUse.push(useSpecialAbility(playersWithSpecials[i], gameId, message, players));
        }
        //Promise.all(specialsToUse).then(r = &gt; console.log(r));
      }
    });
  }
  
  
  // Using promise below because some of the role will have database updates.
  function useSpecialAbility(playerData, gameId, message, players) {
    return new Promise(function(resolve, reject) {
      if (playerData.role === 'seer') {
        let getTargetData = _.find(players, {
          id: playerData.targetId
        });
        message.guild.members.get(playerData.id).send(`Your target is a ${getTargetData.role}!`);
        resolve('foo');
      }
    });
  }
  </code></pre>