Skip to content

Latest commit

 

History

History
70 lines (59 loc) · 3.36 KB

README.md

File metadata and controls

70 lines (59 loc) · 3.36 KB

Cash Suffixes TypeScript

function cashSuffixes TypeScript and JavaScript

Wiki : Cash Suffixes

Thai Sub : README.th.md

Function cashSuffixes TypeScript cashSuffixes.ts
Function cashSuffixes JavaScript cashSuffixes.js

  • if cashSuffixes(0) will get results 0
  • if cashSuffixes(10) will get results 16
  • if cashSuffixes(100) will get results 195
  • if cashSuffixes(1200) will get results 1.2k
  • if cashSuffixes(55000) will get results 55k
  • if cashSuffixes(956243) will get results 956.24k
  • if cashSuffixes(1060715) will get results 1.06M
  • if cashSuffixes(5054098846) will get results 5.05B

Example :

  1. console.log(cashSuffixes(50000000000))
    //Output: 50B
  2. console.log(cashSuffixes(50060000000))
    //Output: 50.06B
  3. console.log(cashSuffixes(50500013502))
    //Output: 50.50B
  4. console.log(cashSuffixes(50500013502, 5))
    //Output: 50.50001B
  5. console.log(cashSuffixes(50500013502, 5))
    //Output: 50.50001B
  6. console.log(cashSuffixes(50568200000, 20))
    //Output: 50.5682B
  7. console.log(cashSuffixes(50568200001, 20))
    //Output: 50.568200001B
  8. console.log(cashSuffixes(505682000154654998400, 20))
    //Output: 505.682000154655undefined

Add a cash suffix that variable types can be as many as you want.
Example :

const types = ['', 'k', 'M', 'B', 'T', 'qd', 'Qn', 'sx', 'Sp', 'O', 'N'];

Developer