title: fs.readdir returns undefined when called inside a function
body: <p>I am trying to write a function that takes a path and returns all the files inside that directory.</p>
  
  <p>When I do this:</p>
  
  <pre><code>function getDirectories(path) {
    fs.readdir(path, function(err, content) {
      if (err) {
        return err;
      } else {
        return content;
      }
    });
  }
  
  console.log(getDirectories('./XML/'));
  </code></pre>
  
  <p>I get <code>undefined</code> in the console.</p>
  
  <p>But when I do this:</p>
  
  <pre><code>function getDirectories(path) {
    fs.readdir(path, function(err, content) {
      if (err) {
        return err;
      } else {
        console.log(content);
      }
    });
  }
  </code></pre>
  
  <p>I get the expected array with file names as strings.</p>
  
  <p>What am I doing wrong?</p>