title: How to round to two decimals with fixed(2)
body: <p>A part of my code deals with math and summations. Most of the equations equal out to be three decimals, but I want to fix it at 2. I know to use tofixed(2), but it doesn't seem to matter where I put the function, the numbers remain at three decimals. I'm sure I'm making some stupid mistake</p>
  
  <pre><code>  &lt;script language="JavaScript"&gt;
  
        function SetFoodItems(amount) {
          // returns the amount in the .99 format
          return (amount == Math.floor(amount)) ? amount + '.00' : ((amount * 10 
     == Math.floor(amount * 10)) ? amount + '0' : amount);
        }
  
        function SelectFoodItems(form) {
          var UpdateCosts = (form.quantity.value - 0) * (form.unitcost.value - 
         0) + (form.quantity1.value - 0) * (form.unitcost1.value - 0) 
         (form.quantity2.value - 0) * (form.unitcost2.value - 0) + 
          (form.quantity3.value - 0) * (form.unitcost3.value - 0).toFixed(2);
  
          UpdateCosts = Math.floor((subtotal * 1000) / 1000).toFixed(2);
          form.subtotal.value = ('$' + cent(subtotal));
  
          var tax = (UpdateCosts / 100 * (form.rate.value - 0).toFixed(2);
          tax = Math.floor(tax * 1000) / 1000;
          form.tax.value = '$' + cent(tax);
  
          total = UpdateCosts + tax;
          total = Math.floor((total * 1000) / 1000);
          form.total.value = ('$' + cent(total)).toFixed(2);
        }
  
  
  
      &lt;/script&gt;
  </code></pre>