title: Limit to 2 decimals result in JavaScript
body: <p>I have an issue with the decimals in a result in my script, it gives unlimited decimals, I want to limit it to 2, I have tried using to.fixed(2) without luck, but the script broke.</p>
  <p>This is my script:</p>
  <pre><code>    $.each(rows, function () {
      quantity = $(this).find('[data-quantity]').val();
      if (quantity == '') {
          quantity = 1;
          $(this).find('[data-quantity]').val(1);
      }
      _amount = parseFloat($(this).find('td.rate input').val()) * quantity;
  
      $(this).find('td.amount').html(_amount);
      subtotal += _amount;
      row = $(this);
      item_taxes = $(this).find('select.tax').selectpicker('val');
      if (item_taxes) {
          $.each(item_taxes, function (i, taxname) {
              taxrate = row.find('select.tax [value=&quot;' + taxname + '&quot;]').data('taxrate');
              calculated_tax = (_amount / 100 * taxrate);
  
  
              if (!taxes.hasOwnProperty(taxname)) {
                  if (taxrate != 0) {
                      _tax_name = taxname.split('|');
                      tax_row = '&lt;tr class=&quot;tax-area&quot;&gt;&lt;td&gt;' + _tax_name[0] + '(' + taxrate + '%)&lt;/td&gt;&lt;td id=&quot;tax_id_' + slugify(taxname) + '&quot;&gt;&lt;/td&gt;&lt;/tr&gt;';
                      $(discount_area).after(tax_row);
                      taxes[taxname] = calculated_tax;
                  }
              } else {
                  // Increment total from this tax
                  taxes[taxname] = taxes[taxname] += calculated_tax;
              }
          });
      }
  });
  </code></pre>
  <p>The code line that does the operation is:</p>
  <pre><code>calculated_tax = (_amount / 100 * taxrate);
  </code></pre>