¡@

Home 

javascript Programming Glossary: abbrnum

Is there a way to round numbers into a reader friendly format? (e.g. $1.1k)

http://stackoverflow.com/questions/2685911/is-there-a-way-to-round-numbers-into-a-reader-friendly-format-e-g-1-1k

question Here is a simple function to do it function abbrNum number decPlaces 2 decimal places 100 3 1000 etc decPlaces Math.pow.. abbrev i We are done... stop break return number Outputs abbrNum 12 1 12 abbrNum 0 2 0 abbrNum 1234 0 1k abbrNum 34567 2 34.57k.. done... stop break return number Outputs abbrNum 12 1 12 abbrNum 0 2 0 abbrNum 1234 0 1k abbrNum 34567 2 34.57k abbrNum 918395..