title: Anonymous Promises
body: <p>So promises is fairly new to me but I love the idea.</p>
  <h2>Previously...</h2>
  <p>I have previously used this which simply returns the data only after file is read completely and works as intended:</p>
  <pre><code>function something{
       for (var i = 0; i &lt; files.length; i++) {
           //push to the array
           promises.push(readFile(files[i]));
       }
  
       //use reduce to create a chain in the order of the promise array
       promises.reduce(function (cur, next) {
           return cur.then(next);
       }, Promise.resolve()).then(function () {
           //all files read and executed!
       }).catch(function (error) {
           //handle potential error
       });
  }
  
  function readFile(file) {
   return new Promise(function (resolve, reject) {
       var reader = new FileReader();
       reader.onload = function (progressEvent) {
           loadGeoJsonString(progressEvent.target.result, file.name);
           resolve();
       }
  
       reader.onerror = function (error) {
           reject(error);
       }
  
       reader.readAsText(file);
   });
  }
  </code></pre>
  <h2>Currently</h2>
  <p>I want to redo this by using &quot;,then&quot; and &quot;.catch&quot; to handle success and non-successes. In my current solution (Google Maps API for clarification but is irrelevant) I want to promise a function without returning a promise in the original function. This is what I have:</p>
  <pre><code>//create infobox object on marker
  function createInfobox(lat, lng) {
  var pos = new G.LatLng(lat, lng);
  
  promiseThis(dropMarker, pos, 'drop marker')
      .then(promiseThis(getGeocodeResult, pos, 'get address'))
      .catch(reason =&gt; {alert(reason)})
      .then(promiseThis(isDeliverable, pos, 'determine deliverable status'))
      .catch(reason =&gt; {alert(reason)})
      .then(promiseThis(getStores, pos, 'find stores'))
      .catch(reason =&gt; {alert(reason)});
  }
  
  //handle promises
  function promiseThis(doThis, withThis, task) {
      return new Promise(function (resolve, reject) {
          var result = doThis(withThis);
          if (result) {
              resolve(result);
          } else {
              reject('Unable to ' + task);
          }
      });
  }
  
  //drop marker on location
  function dropMarker(location) {..} //return object
  
  //get geocode results
  function getGeocodeResult(latlng) {..} //return string
  </code></pre>
  <p>In the end I would like to keep the results from each promise in an array and use it later. At the moment the getGeocodeResult just returns 'Unable to get address' immediately (also as a console error, not as an alert)</p>
  <p>What do I need to know about promises to make this work?</p>