Advertisement
devoresyah

JS Format Number to K & M

Sep 23rd, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function kFormat(num) {
  2.     return num > 999 ? (num/1000).toFixed(1) + ' K' : num
  3. }
  4. function mFormat(num) {
  5.     return num > 99999 ? (num/1000000).toFixed(1) + ' M' : num
  6. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement