Answers for "javascript change long digit ot k,m"

0

javascript change long digit ot k,m

function nFormatter(num) {
     if (num >= 1000000000) {
        return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'G';
     }
     if (num >= 1000000) {
        return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
     }
     if (num >= 1000) {
        return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
     }
     return num;
}
Posted by: Guest on September-01-2021

Code answers related to "javascript change long digit ot k,m"

Code answers related to "Javascript"

Browse Popular Code Answers by Language