Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert number to k m b javascript

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #number #javascript
ADD COMMENT
Topic
Name
1+3 =