Posted By

sikwan on 10/14/10


Tagged

javascript format


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

verostudios


Format Money


 / Published in: JavaScript
 

This function format a number to looks like a price.

  1. function formatAsMoney(mnt) {
  2. mnt -= 0;
  3. mnt = (Math.round(mnt*100))/100;
  4. return (mnt == Math.floor(mnt)) ? mnt + '.00'
  5. : ( (mnt*10 == Math.floor(mnt*10)) ?
  6. mnt + '0' : mnt);
  7. }

Report this snippet  

You need to login to post a comment.