title: How to return many Promises and wait for them all before doing other stuff
body: <p>I have a loop which calls a method that does stuff asynchronously. This loop can call the method many times. After this loop, I have another loop that needs to be executed only when all the asynchronous stuff is done.</p>
  <p>So this illustrates what I want:</p>
  <pre><code>for (i = 0; i &lt; 5; i++) {
      doSomeAsyncStuff();    
  }
  
  for (i = 0; i &lt; 5; i++) {
      doSomeStuffOnlyWhenTheAsyncStuffIsFinish();    
  }
  </code></pre>
  <p>I'm not very familiar with promises, so could anyone help me to achieve this?</p>
  <p>This is how my <code>doSomeAsyncStuff()</code> behaves:</p>
  <pre><code>function doSomeAsyncStuff() {
      var editor = generateCKEditor();
      editor.on('instanceReady', function(evt) {
          doSomeStuff();
          // There should be the resolve() of the promises I think.
      })
  }
  </code></pre>
  <p>Maybe I have to do something like this:</p>
  <pre><code>function doSomeAsyncStuff() {
      var editor = generateCKEditor();
      return new Promise(function(resolve,refuse) {
          editor.on('instanceReady', function(evt) {
              doSomeStuff();
              resolve(true);
          });
      });
  }
  </code></pre>
  <p>But I'm not sure of the syntax.</p>