title: JavaScript append array to array from loop
body: <p>I have the below Table TDs that I need to get the values.</p>
  
  <pre><code>     &lt;table style="border: 1px solid blue;margin: 15px;"&gt;
          &lt;tr&gt;
              &lt;td class="drdsclient"&gt;DSCDS201020101&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="drcheck"&gt;
              &lt;td&gt;Maximum online generations:&lt;/td&gt;
              &lt;td id="drcheckval" class="notopborder"&gt;30&lt;/td&gt;
              &lt;td id="drchecknotes" class="notopborder"&gt;notes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="drcheck"&gt;
              &lt;td&gt;Default Retention Rule set:&lt;/td&gt;
              &lt;td id="drcheckval" class="notopborder"&gt;No default Retention rule set&lt;/td&gt;
              &lt;td id="drchecknotes" class="notopborder"&gt;notes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="drcheck"&gt;
              &lt;td&gt;Default Backup Schedule set:&lt;/td&gt;
              &lt;td id="drcheckval" class="notopborder"&gt;No default Schedule set&lt;/td&gt;
              &lt;td id="drchecknotes" class="notopborder"&gt;notes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="drcheck"&gt;
              &lt;td class="drdsclient"&gt;DSCDS901999102&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="drcheck"&gt;
              &lt;td&gt;Maximum online generations:&lt;/td&gt;
              &lt;td id="drcheckval"  class="notopborder"&gt;29&lt;/td&gt;
              &lt;td id="drchecknotes" class="notopborder"&gt;notes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="drcheck"&gt;
              &lt;td&gt;Default Retention Rule set:&lt;/td&gt;
              &lt;td id="drcheckval"  class="notopborder"&gt;30 days&lt;/td&gt;
              &lt;td id="drchecknotes" class="notopborder"&gt;notes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="drcheck"&gt;
              &lt;td&gt;Default Backup Schedule set:&lt;/td&gt;
              &lt;td id="drcheckval"  class="notopborder"&gt;Monday to Friday @ 21:00&lt;/td&gt;
              &lt;td id="drchecknotes" class="notopborder"&gt;notes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>I keep using IDs and Classes with the below JS code:</p>
  
  <pre><code>    var array1 = [];
          $(' .drdsclient ').each(function(){
              var obj = { 
                  drdsc: $(" .drdsclient ").text(),
                  drcheck1: $(" #drcheck1 " ).text(),
                  drcheckval1: $(" #drcheckval1 ").text(),
                  drchecknotes1: $(" #drchecknotes1 ").text(),
                  drcheck2: $(" #drcheck2 " ).text(),
                  drcheckval2: $(" #drcheckval2 ").text(),
                  drchecknotes2: $(" #drchecknotes2 ").text(),
                  drcheck3: $(" #drcheck3 " ).text(),
                  drcheckval3: $(" #drcheckval3 ").text(),
                  drchecknotes3: $(" #drchecknotes3 ").text()
              };
              var arr2 = array1.push(obj);
          });
  </code></pre>
  
  <p>But instead of appending to the array, it doubles the values and I get the below result:</p>
  
  <pre><code>[0]
      [drdsc] =&gt; "DSCDS201020101DSCDS901999102"
      [drcheck1] =&gt; "Maximum online generations:Maximum online generations:"
      [drcheckval1] =&gt; "30999"
      [drchecknotes1] =&gt; "notesnotes"
      [drcheck2] =&gt; "Default Retention Rule set:Default Retention Rule set:"
      [drcheckval2] =&gt; "No default Retention rule set30 days"
      [drchecknotes2] =&gt; "notesnotes"
      [drcheck3] =&gt; "Default Backup Schedule set:Default Backup Schedule set:"
      [drcheckval3] =&gt; "No default Schedule setMonday to Friday @ 21:00"
      [drchecknotes3] =&gt; "notesnotes"
  [1]
      [drdsc] =&gt; "DSCDS201020101DSCDS901999102"
      [drcheck1] =&gt; "Maximum online generations:Maximum online generations:"
      [drcheckval1] =&gt; "30999"
      [drchecknotes1] =&gt; "notesnotes"
      [drcheck2] =&gt; "Default Retention Rule set:Default Retention Rule set:"
      [drcheckval2] =&gt; "No default Retention rule set30 days"
      [drchecknotes2] =&gt; "notesnotes"
      [drcheck3] =&gt; "Default Backup Schedule set:Default Backup Schedule set:"
      [drcheckval3] =&gt; "No default Schedule setMonday to Friday @ 21:00"
      [drchecknotes3] =&gt; "notesnotes" 
  </code></pre>
  
  <p>Any way I can get an array like the below?</p>
  
  <pre><code>[0]
      [drdsc] =&gt; "DSCDS201020101"
      [drcheck1] =&gt; Maximum online generations:"
      [drcheckval1] =&gt; "30"
      [drchecknotes1] =&gt; "notes"
      [drcheck2] =&gt; "Default Retention Rule set:"
      [drcheckval2] =&gt; "No default Retention rule set"
      [drchecknotes2] =&gt; "notes"
      [drcheck3] =&gt; "Default Backup Schedule set:"
      [drcheckval3] =&gt; "No default Schedule set"
      [drchecknotes3] =&gt; "notes"
  [1]
      [drdsc] =&gt; "DSCDS901999102"
      [drcheck1] =&gt; "Maximum online generations:"
      [drcheckval1] =&gt; "999"
      [drchecknotes1] =&gt; "notes"
      [drcheck2] =&gt; "Default Retention Rule set:"
      [drcheckval2] =&gt; "30 days"
      [drchecknotes2] =&gt; "notes"
      [drcheck3] =&gt; "Default Backup Schedule set:"
      [drcheckval3] =&gt; "Monday to Friday @ 21:00"
      [drchecknotes3] =&gt; "notes" 
  </code></pre>