title: Update schedule displayed based on new updated arrayjQuery
body: <p>I am part way through a project where I have to display a charge schedule based off a number of variables that are inputted from the user.</p>
  <p>I have got all the data and updated the array based off a priority number calculated from the data.</p>
  <p>I am having trouble now using the updated array to generate the schedule.</p>
  <p>The code below represents the part I think is where it needs to go.</p>
  <pre><code>
  Updated array =  &quot;regss_sorted&quot;
  
  reggs_sorted;
  
    //loop through second table starting from tr eq 0
         $(&quot;#table_id_2 tbody tr:eq(&quot; + count + &quot;)&quot;).each(function() {
          //  start based on sorted prioirty 
          
          
          $(this).find(&quot;td:eq(0)&quot;).text(car1_name);//set car_name
    //if hrs = 11 and leaves = 2 so loop from 11 -10-9-8..
    // add conditonal here for solar will need help writing this. 
          for (var i = hrs; i &gt;= leaves; i--) {
          //add bg to that td
            $(this).find(&quot;td[value=&quot; + i + &quot;]&quot;).css({
              &quot;background-color&quot;: &quot;#00417b&quot;
            });;
  
          // add exit miles 
          $(this).find(&quot;.exit&quot;).text(mtnc)
        }
        });
        count++;//increment to go to next tr 
      });
    }); 
  </code></pre>
  <p>the I have tried a lot of different ways, and looked on Stack but I can't find the answer or even a similar question. Any help would be appreciated.</p>
  <p>Full fiddle found here: Updated Fiddle with a bug fix to show correct priority number <a href="https://jsfiddle.net/Coxy/184vysjp/2/" rel="nofollow noreferrer">https://jsfiddle.net/Coxy/184vysjp/2/</a></p>