title: Why this code still adding rows to the table if indexOf return 0?
body: <p>I've this jQuery that allow to add new rows to a table on click event of a button but only if the <code>id</code> value isn't already added.</p>
  
  <pre><code>var factAgregada = [];
  
  $('#btnAgregarFactura').on("click", function (e) {
      e.preventDefault();
  
      // no_factura and fecha_factura comes from a modal window 
      // it's not relevant to show that part here
  
      var no_factura = $("#no_factura").val(), 
          fecha_factura = $("#fecha_factura").val(),
          html;
  
      console.log(no_factura);
      console.log(factAgregada.indexOf(no_factura));
  
      if (factAgregada.indexOf(no_factura) &gt;= -1) {
          html = '&lt;tr&gt;';
          html += '&lt;td&gt;&lt;input type="checkbox" id="' + no_factura + '"&gt;&lt;/td&gt;';
          html += '&lt;td&gt;' + no_factura + '&lt;/td&gt;';
          html += '&lt;td&gt;' + fecha_factura + '&lt;/td&gt;';
          html += '&lt;/tr&gt;';
  
          $(html).appendTo("#facturaBody");
      }
  
      factAgregada.push(no_factura);
  });
  </code></pre>
  
  <p>On first execution the code works fine and <code>console.log()</code> outputs this:</p>
  
  <pre><code> 12
   -1
  </code></pre>
  
  <p>So it's right add the row, but on second execution and keeping the same value <code>console.log()</code> changes from the previos values to this ones:</p>
  
  <pre><code>12
  0
  </code></pre>
  
  <p>So, row shouldn't be added but still adding to the table and continue doing the <code>appendTo()</code>, what's wrong there? What I'm not seeing?</p>