title: Making forEach wait for callback
body: <p>New to async programming so I just can't figure how to do this:</p>
  
  <pre><code>$results = [];
  
  products.forEach(function (product) {
  
    // 1. Search ...
    google(keyword, function (err, res) {
      if (err) console.error(err)
  
      for (var i = 0; i &lt; res.links.length; ++i) {
        var result = res.links[i];
        var obj = {
          title: res.links[i].title,
          href: res.links[i].href,
          description: res.links[i].description
        }
        results.push(obj); // 2. store each result in results Array
      }
    }, processData); // 3. send all results to processData when done
  
    // 5. NOW, itereate further ...
  
  });
  
  function processData(results) {
    console.log('processing data');
    // 4. save results to DB
  }
  </code></pre>
  
  <p>Since the process requires making HTTP requests, collecting data and then saving to DB which all takes time, so I don't want forEach to advance to the next element until one is done. </p>