title: node.js multiple asynchronous functions
body: <pre><code>var http = require('http');
  var res = ["","",""];
  for(i =2;i&lt;5;i++){
     http.get(process.argv[i],function(response){
             response.setEncoding('utf8');
             str = "";
             count =i-2;
             response.on("data", function(data) {
                     str = str.concat(data);
             });
             response.on("end", function() {
                     res[count] = str;
                     console.log(count);
                     console.log(res[count]);
             });
     });
  }
  
  while(true) {
      if(res[0]!==""&amp;&amp;res[1]!==""&amp;&amp;res[2]!=="")
      {
             console.log(res[0]);
             console.log(res[1]);
             console.log(res[2]);
             break;
      }
  }
  </code></pre>
  
  <p>I will have three URLs as the first three command-line arguments. My job is to collect the data from each of the URL's as strings and print them to console in the order they appeared in command line. Right now the code does not print anything and it is stuck in an infinite loop. What is wrong?</p>