title: How to chain promises in for loop in vanilla javascript
body: <p>If I am doing an async call like the following, how can chain them with promises, so i can do stuff in order? In this example, what ends up happening is that <code>arr</code> will push the items out of order. I'd prefer an answer with promises, but anything will do as long as it works</p>
  
  <pre><code>var fbArrOfAlbumNames = ['Profile Pictures', 'Cover Photos', 'Mobile Uploads'];
  var arr = [];
  for(var x = 0; x &lt; fbArrOfAlbumNames.length; x++) {
    (function(cntr) {
      FB.api('/' + fbArrOfAlbumNames[cntr] + '/photos/', {fields: 'picture,album'}, function(response) {
        arr.push(response);
      }
    })(x);
  }
  </code></pre>