title: How do I Iterate through the whole array before callback on nodejs?
body: <p>I'm trying to iterate through the whole array before the callback. I'm beginner on nodejs and I'm still grasping how to use the concept of callback.</p>
  
  <p>Bumped into async.eachSeries / mapSeries / waterfall and I'm trying different combinations but none work. </p>
  
  <p>I'd like to ensure that the calls to the tasks on the waterfall array are executed for both arrays on eachSeries (myExchanges and signalso) before calling back. </p>
  
  <pre><code>async.eachSeries(myExchanges, function (exchange, outerCB){         
          async.eachSeries(signalso, function(signal,innerCB){                                
              let thisExchangeBuckets = Object.values(custCurrBalance).filter(bal=&gt; bal.exchange===exchange.id)
              var tasko = [async.apply(sigo, signal,exchange, thisExchangeBuckets),availableBalancesC, availableSymbolsC, executeOrders]  
              const response =  async.waterfall(tasko, (err, results) =&gt; {
                  thisOrders.push(results)                                
                  var json = JSON.stringify(thisOrders,null,2);
                  fs.writeFileSync(newBalFilePath,json);                  
              })
              innerCB(null);
          },
          function(err) 
          {
              outerCB(null);  // outer callback
          });
      },
      function(err) 
      {
          console.log('all done!!!');
      });
      processAllCB(thisOrders);
  </code></pre>
  
  <ol>
  <li>results at doAll undefined (this one comes from the called back function)</li>
  <li>all done!!! (this one comes from the last code line provided above)</li>
  <li>HERE Im getting the execution of the functions on waterfall</li>
  </ol>
  
  <p>I expect</p>
  
  <ol>
  <li>functions of waterfall</li>
  <li>all done!!!</li>
  <li>results at doAll [array of placed orders]</li>
  </ol>