JavaScript round val to 2 decimal places

I have a script to calculate checkboxes as they are selected:

$('input:checkbox').change(function () {
  var total = 0;
  $('input:checkbox:checked').each(function () {
    total += isNaN(parseInt($(this).val())) ? 0 : parseInt($(this).val());
  });
  $("#total").val(total);
});

The total is showing as 46 rather than 46.00 for example. How can I ensure the number is always showing to 2 decimal places?

I added

console.log(format(total));

Which showed the correct format…

Answer

total = parseFloat(total).toFixed(2);