title: Changing <td> background color according to array received as AJAX response
body: <p>I'm trying to change my  background-color according to values on an array.
  So cose seems to work but i keep receing ALL  with only one color, instead of having it doing the validation and selecting the color accordingly.</p>
  
  <p>I have already tried with JQUERY to do this based on AJAX response. Console says it works, my site says otherwise. I really need help.</p>
  
  <p>The code below is one of my AJAX functions. It should print 1 green and 4 brown/red ones. Still I keep getting either all red or all greens.</p>
  
  <p>This is the array received <code>[1776220,17 ,242332 ,1119098, 500633]</code></p>
  
  <pre class="lang-js prettyprint-override"><code>function listThem() {
    let color = '';
    $.ajax({
      type: "GET",
      url: "php/vehiculos/testServicio.php",
      data: "data",
      success: function(response) {
        let dinamica = JSON.parse(response);
        //VARIABLE PARA DINÁMICA DE SERVICIO COMUNITARIO
        //Aquíiiiiiiiii we are trying to reset
        $.each(dinamica, function(i, elem) {
          if (dinamica[i] &lt;= 86400) {
            console.log(elem);
            color = '#51d847';
          }
          if ((dinamica[i] &gt; 86400) &amp; (dinamica[i] &lt; 172800)) {
            console.log(elem);
            color = '#F18D05';
          }
          if (dinamica[i] &gt;= 172800) {
            console.log(elem);
            color = '#E54028';
          }
        });
      }
    });
  }
  
  $.ajax({
    url: 'php/vehiculos/listing.php',
    type: 'GET',
    success: function(response) {
      /** Lets convert the string-like response into an usable object */
      let trueList = JSON.parse(response);
      // Some console checking
      console.log(trueList);
      /**Template that will be send to the HTML */
      let template = '';
      trueList.forEach(vehiculo =&gt; {
        /** Some back-ticks magics */
        template += `&lt;tr taskId=${vehiculo.posId} &gt; &lt;!-- PAY ATENTION HERE--&gt;
           &lt;td class=''&gt;
               &lt;a&gt;${vehiculo.name}&lt;/a&gt;
           &lt;/td&gt;
           &lt;td style='background-color:${color}';&gt;
               ${vehiculo.ultimaUpdate}  
           &lt;/td&gt;
           &lt;td&gt;${vehiculo.phone}&lt;/td&gt;
           &lt;td&gt;${vehiculo.category}&lt;/td&gt;
          &lt;/tr&gt;`
        $('#registros').html(template);
      });
    }
  })
  </code></pre>