Created
March 11, 2021 01:31
-
-
Save IgorHalfeld/13325a8162bb05d9ccf9a1aa00844797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const abbreviationNumber = number => { | |
const qtdMulti = number / 1000; | |
if (qtdMulti >= 1 && qtdMulti < Math.pow(10, 3)) { | |
return number / Math.pow(10, 3) + 'K'; | |
} | |
if (qtdMulti >= Math.pow(10, 3) && qtdMulti < Math.pow(10, 6)) { | |
return number / Math.pow(10, 6) + 'M'; | |
} | |
if (qtdMulti >= Math.pow(10, 6) && qtdMulti < Math.pow(10, 9)) { | |
return number / Math.pow(10, 9) + 'G'; | |
} | |
return number; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment