title: NodeJS loop wait for callback
body: <p>How can i wait inside a for loop until the callback was received and then continue the for loop?</p>
  
  <p>Here's my loop:</p>
  
  <pre><code>for(var i = 0; i &lt; offer.items_to_receive.length; i++) {
      console.log("Waiting for callback...");
      doSomething(function(data) {
          console.log("Got data from callback! "  + data);
      });
      console.log("Continue for loop now.");
  }
  </code></pre>
  
  <p>Thanks for inputs!</p>