title: Serial Execution of Promise
body: <p>I would like to execute a function with a parameter looping from an array of values. Every execution must waits the previous to be completed.
  The example code below should print:</p>
  
  <pre><code>Done: 1
  Done: 2
  Done: 3
  Done: 4
  Done: 5
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>p.</p>
  
  <pre class="lang-js prettyprint-override"><code>'use strict';
  
  function f1(value) {
      return new Promise((resolve, reject) =&gt; {
          setTimeout(function() {
              console.log('Done: ' + value);
              resolve(true)
          }, Math.random() * 2000 + 1000);
      });
  }
  
  const vs = [0,1,2,3,4,5];
  
  vs.reduce((start, next) =&gt; {
      return f1(next)
  })
  </code></pre>