title: Async/await in foreach not waiting
body: <p>I'm trying to use <code>async</code> and <code>await</code> in a function that uses a <code>forEach</code> loop. Annoyingly I can't get it to work. What should happen is it takes an array of event <code>docs</code>, loops through them, adds in some extra data, then pushes them to the <code>events</code> array. This <code>events</code> array is then returned from the original function. Here is my code:</p>
  
  <pre><code>async function getEvents() {
    ...
    var events = []
    await addExtrasToDocsForUser(docs, currentUserId, events)
    return events
  
  }
  
  
  var addExtrasToDocsForUser = (docs, currentUserId, events) =&gt; {
      return docs.forEach(async (eventDoc) =&gt; {
          const event = await addExtrasToDocForUser(eventDoc, currentUserId)
          events.push(event)
      })
  }
  </code></pre>
  
  <p>What actually happens is the <code>getEvents()</code> function returns <code>events</code> as an empty array before the <code>forEach</code> loop has completed. How do I fix this?</p>