title: async each and foreach functions
body: <p>I'm trying to use async's each function to call the abc function, and I am running into a couple problems. The code is as follows.</p>
  
  <ol>
  <li><p>The reason why I am using the for loop here is because when I tried to use each function, the url that's passed into the abc function's url is in the form of array instead of string. So I'm wondering if there's any other way to clear this up without having to add the for loop. </p></li>
  <li><p>After adding a couple print statements, I realized that the code never executes pass http.get(url[a], newFileLoc, function (error, result){ for some reason. There's always an error message "async.each(urls, downloadFile(urls, function(){
  TypeError: Object # has no method 'each'"</p></li>
  <li><p>So I guess my real question is, what exactly is wrong with the code? I tried to use forEach instead of each, but there was still another error "iterator(x, function (err) {
  TypeError: undefined is not a function". </p></li>
  </ol>
  
  <p>Someone please help out!!!</p>
  
  <pre><code>var abc = function ( url, cb ) {
    for (var a = 0; a &lt; url.length; a++){
      var index = url[a].lastIndexOf("/") + 1;
      var filename = url[a].substr(index);
      var newFileLoc = "./tmp/" + filename;
      http.get(url[a], newFileLoc, function (error, result) {
        if (error) {
          console.error(error);
        } else {
          cb();
        }
      });
    }
  }
  var urls = ["www.randomurl.random.random/", "www.randomurl.random.random/"];
  
  async.each(urls, abc(urls, function(){
    console.log('downloaded' + results);
  }), function(err){       
    if(err){
      console.log(err);
    }
  });
  </code></pre>