title: JavaScript round val to 2 decimal places
body: <p>I have a script to calculate checkboxes as they are selected:</p>
  <pre><code>$('input:checkbox').change(function () {
    var total = 0;
    $('input:checkbox:checked').each(function () {
      total += isNaN(parseInt($(this).val())) ? 0 : parseInt($(this).val());
    });
    $(&quot;#total&quot;).val(total);
  });
  </code></pre>
  <p>The <code>total</code> is showing as <code>46</code> rather than <code>46.00</code> for example. How can I ensure the number is always showing to 2 decimal places?</p>
  <p>I added</p>
  <pre><code>console.log(format(total));
  </code></pre>
  <p>Which showed the correct format...</p>