title: Sum numbers with JavaScript doesn't work properly "Intl.NumberFormat"
body: <p>I have page with table of products and for each product there is a price.
  When I change the qty it gets the total price...</p>
  <p>But I have this problem:
  When the numbers are lower then &quot;1,000&quot;, the sum is ok.</p>
  <p>ex:</p>
  <ol>
  <li>prod 1: 200</li>
  <li>prod 2: 200</li>
  <li>prod 3: 500</li>
  <li><strong>total: 900</strong></li>
  </ol>
  <p>But when the numbers are greater then &quot;1,000&quot;, the comma is the problem. I get a wrong answer.</p>
  <p>ex:</p>
  <ol>
  <li>prod 1: 200</li>
  <li>prod 2: 1,200</li>
  <li>prod 3: 300</li>
  <li><strong>total: 501</strong></li>
  </ol>
  <p>When I remove the &quot;Intl.NumberFormat&quot; from the total of each product, I get the right answer, but for some cases I get numbers like this: &quot;1.000031545&quot;,
  which I don't need. I only need the first 2 digit after the dot.</p>
  <p><strong>CODE: (simplefied)</strong></p>
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
         &lt;td style=&quot;text-align: center;&quot;&gt;
             &lt;label for=&quot;prod[&lt;?php echo $prodid; ?&gt;]&quot;&gt;&lt;input class='qty' style=&quot;font-size: 12px;&quot; type=&quot;text&quot; name=&quot;qty_&lt;?php echo $prodid; ?&gt;&quot; placeholder=&quot;qty&quot; minlength=&quot;1&quot; maxlength=&quot;3&quot; size=&quot;2&quot;&gt;&lt;/label&gt;
         &lt;/td&gt;
         &lt;td class='price'&gt;
             &lt;?php echo $prodprice; ?&gt;
         &lt;/td&gt;
         &lt;td width=&quot;40&quot; class=&quot;sum&quot;&gt;0&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
         &lt;td colspan=&quot;3&quot;&gt;
             &lt;span class=&quot;output&quot;&gt;&lt;/span&gt;
         &lt;/td&gt;
  &lt;/table&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
  
  function getTotal(){
      var total = 0;
      $('.sum').each(function(){
          total += parseFloat(this.innerHTML);
      });
  
      $('#total').text(total);
  
              givenNumber = total; 
              nfObject = new Intl.NumberFormat('en-US'); 
              output = nfObject.format(givenNumber); 
              document.querySelector('.output').textContent = total; 
  }
  
  getTotal();
  
  $('.qty').keyup(function(){
      var parent = $(this).parents('tr');
      var price = $('.price', parent);
      var sum = $('.sum', parent);
      var value = parseInt(this.value) * parseFloat(price.get(0).innerHTML||0);
              givenNum1 = value; 
              nfObj = new Intl.NumberFormat('en-US'); 
              outpu = nfObj.format(givenNum1); 
      sum.text(outpu);
      getTotal();
  })
  
  &lt;/script&gt;
  </code></pre>