title: Javascript array push in a for loop
body: <p>I have two <code>for loops</code> on the second one I am using <code>push</code> to an array called <code>myArray</code> and it is not pushing the data has desired. Returning the array to the console in the second <code>for loop</code> outputs the following:</p>
  
  <pre><code>["Scottsdale CFS"]
  ["Scottsdale CFS", "Denver CFS"]
  ["Warren CFS"]
  ["Warren CFS", "Millford CFS"]
  ["Rockaway CFS"]
  ["Rockaway CFS", "Border CFS"] 
  </code></pre>
  
  <p>However, I would like the data to show like this:</p>
  
  <pre><code>["Scottsdale CFS", "Denver CFS", "Warren CFS", "Millford CFS", "Rockaway CFS", "Border CFS"]
  </code></pre>
  
  <p>How can I accomplish this?</p>
  
  <p>note: The reason it is showing up like that is because I am iterating through a JSON file which checks through the first center and retrieves the data in an array and then goes to the next and does the same. The problem is that the arrays each have two elements which is why I am trying to <code>push</code> it into one array.</p>
  
  <pre><code>var looper = function(sec0, vz, lOrR) {                                
  
      var myArray = [];
  
         for(var i=0;i&lt;vz[0]['Areas'].length;i++){
            var tText = Object.keys(vz[0]['Areas'][i]); 
            var root = vz[0]['Areas'][i][tText][0];                         
            var dataName;
         }
  
         var myArray = [];                                                                  
  
      if(sec0 === "Centers") {
  
        for(var j=0;j&lt;root[sec0].length;j++){
  
          var myString = root[sec0][j]["Label"];
  
          myArray.push(myString);
  
  
          charts.chart.renderTo = lOrR+myArray.indexOf(root[sec0][j]["Label"]);   
          charts.title.text = root[sec0][j]["Label"];
          dataName = root[sec0][j]['Metrics'][5]['Rep Res. %'].slice(0,-1); 
          charts.series[0].name = dataName;    
          charts.series[0].data = [parseFloat(dataName)];
          new Highcharts.Chart(charts);
  
  
           }                                            
        }
     }
   }
  </code></pre>