showing results for - "javascript change long digit ot k 2cm"
Amelie
06 May 2016
1function nFormatter(num) {
2     if (num >= 1000000000) {
3        return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'G';
4     }
5     if (num >= 1000000) {
6        return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
7     }
8     if (num >= 1000) {
9        return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
10     }
11     return num;
12}
13