title: Javascript File Reader
body: <p>I may just not be understanding the file reader api, but </p>
  
  <p>When I try to run:</p>
  
  <pre><code>for (var i = 0, f1, f2; f1 = files[sorted_index[i]], f2 = files[sorted_index[i+1]]; i=i+2) {
      var file_one;
      var file_two;
  
      if(f1.size &lt; f2.size){
          file_one = f1;
          file_two = f2;
      } else {
          file_one = f2;
          file_two = f1;
      }
  
      var file_one_contents;
      var file_two_contents;
  
  
    var reader = new FileReader();
    reader.readAsText(file_one);
    reader.onload = readSuccess;
  
    function readSuccess(evt){
      file_one_contents = evt.target.result;
    }
    var reader = new FileReader();
      reader.readAsText(file_two);
      reader.onload = readSuccess2;
  
    function readSuccess2(evt2){
      file_two_contents = evt2.target.result;
    }
  
      console.log(file_one_contents);
      console.log(file_two_contents);
  </code></pre>
  
  <p>The console log only contains <em>undefined</em> in it.
  The goal of the script it two read in two CSVs and take the data from the pair of files and do some computations.</p>
  
  <p>Thanks!</p>