title: JavaScript For Loop Keeps Looping Infinity
body: <p>I've written the functions below as part of a much larger application for processing FASTA formatted files via a web interface. For some reason it decided to run into infinity when call upon my baseCounts() function from within makePretty(). It might be worth noting that both functions are encapsulated by the same parent function.</p>
  
  <p>The function baseCounts() returns valid data in the form of a 100+ long array, console.log confirms that it is not to blame so the problem has to be with makePretty(). </p>
  
  <p>Any help is welcome.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function baseCount(records){
    // Count instances of Bases in array
    var basecounts = Array();
    for (i=0; i &lt; records.length; i++){
     var record = records[i];
     console.log(record);
     var count = [record.match(/A/g), record.match(/T/g), record.match(/C/g), record.match(/G/g)];
     var basecount = Array();
     for (i=0; i &lt; count.length; i++){
      basecount.push(count[i].length);    
     }
     // return array of occurance
     basecounts.push(basecount);
    }
   }
   
   function makePretty(fasta){
    // Make FASTA more human friendly
    
    var data = Array();
    var basecounts = Array();
    var bases = Array();
    console.log(fasta.length);
    
    // Generate base array 
    for (i=1; i &lt; fasta.length; i++){
     bases.push(fasta[i][2])
    }
    basecounts = baseCount(bases); // RUNS INTO INFINITY
    
    
    for (i=0; i &lt; fasta.length; i++){
      
     var record = Array();
     record.push(i); // Add protein number
     record.push(fasta[i][0]); // Add NC_#
     record.push(fasta[i][1]); // Add base index
     _record = fasta[i][2];
     var l_record = _fasta.length; // Protein length
     //var basecount = baseCount(_record);
     var cg_content;
     
    }
   }</code></pre>
  </div>
  </div>
  </p>