title: How to return value in sequential forEach loop?
body: <p>This is how I'm using a sequential forEach loop to handle some file uploads. Now I want to get a total result for each upload:
  For each file I resolve with an object (success or error). At the end I want to get a returned array to display the result (File 1 successful, file 2 error and so on).</p>
  <p>But with this code I only get <code>undefined</code> for the last output. What am I missing?</p>
  <p>Maybe it would even be better to return two string arrays: one successful and one failed array with filenames.</p>
  <pre><code>Array.prototype.forEachSequential = async function (
      func: (item: any) =&gt; Promise&lt;void&gt;
  ): Promise&lt;void&gt; {
      for (let item of this) await func(item)
  }
  async uploadFiles(files: [File]): Promise&lt;any&gt; {
      const result = await files.forEachSequential(
          async (file): Promise&lt;any&gt; =&gt; {
          const res = await new Promise(async (resolve, reject) =&gt; {
              // do some stuff
              resolve({ success: file.filename })
              // or maybe
              resolve({ error: file.filename })
          })
          console.log(res) // returns object as expected
          return res
          }
      )
      // Get all results after running forEachSequential
      console.log('result', result) // result: undefined
  })
  </code></pre>