title: retreiving values from a for loop and dynamically adding them to a JSON in an array
body: <p>So I have a for-loop which returns for each result record a</p>
  
  <p>id
  Name
  StartDate
  EndDate</p>
  
  <p>here it is the for-loop below ></p>
  
  <pre><code>     for (var i = 0; i &lt; data.d.results.length; i++) {   
       }  
  </code></pre>
  
  <p>So at the end depending on how many records returned I am going to have a few of these.</p>
  
  <p>What I do want to do is as these records are created dynamically in the loop add them to a json object of mine</p>
  
  <pre><code>  jsonObject= [{
    id: 0, name: Name1, series: [{ start: Startdate1, end: Enddate1  }],
    id: 1, name: Name2, series: [{ start: Startdate2, end: Enddate2  }],
    id: 2, name: Name3, series: [{ start: Startdate3, end: Enddate3  }],
    }];
  </code></pre>
  
  <p>So through the loop the id's 1 get added within the object, then 2 then 3.
  I've been reading up on the .push method but not sure how I structure this one.</p>