title: Display File Name and File Size in CWD in Node.js
body: <p>I'm having trouble with this code. What I'm trying to accomplish is getting a list of the file names and sizes to print on the same line in STDOUT. Currently, I am getting a list of file names, and then a list of sizes, but I want the sizes to display along side the names. I am more familiar with how to do this in Python, and I'm surprised how hard this is to do in JavaScript. So if you could not only help me correct my code, but help me understand how the code is working in JS, then it would be much appreciated. Here is the code:</p>
  <pre><code>const fs = require('fs');
  
  let path = __dirname;
  
  let files = fs.readdirSync(path);
  
  for (var i = 0; i &lt; files.length; i++){
    var fileStats = files[i];
    console.log(&quot;Start: &quot; + fileStats);
    fs.stat(fileStats, function(err, stats){    
      console.log(stats.size);
    });
  }
  </code></pre>
  <p>For comparison, this is what the code would look like in Python</p>
  <pre><code>import os
  import os.path
  
  path = os.getcwd()
  contents = os.listdir(path)
  
  print(path)
  for file in contents:
    size = os.path.getsize(file)
    print(&quot;File: {0}, Size: {1} Bytes&quot;.format(file, size))
  </code></pre>
  <p>Thanks</p>