title: Can't acess variable outside forEach loop JavaScript
body: <p>I want to get the allItems variable outside the function, but I just can get an empty array. The first console.log shows the array I wanted, but the second it's just [].</p>
  <pre><code>var allItems = [];    
  orderPads.forEach(async  element =&gt; {
          
          element.orders_fk.forEach(async elem =&gt; {
              
              let itemsArray = await OrderedItem.find({ order_fk: elem });
              
              
              itemsArray.forEach(async e =&gt; {
                   
                  let temp = e.toObject();
                  const mesa = await Table.findById(element.mesa);
                  temp.mesa = mesa.name;
                  
                  allItems.push(temp)
                  console.log(allItems)
                  
              })
          })
      });
  console.log(allItems)
  </code></pre>
  <p>I've already looked for answers online, but nothing seems to work in this case. Thank you for the help!</p>