See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope> is optional
| var minimizeNumber = (num) => { | |
| if(!Number.isFinite(num)) return ""; | |
| const minimizeMap = ["K", "M", "G", "T", "P", "E"]; | |
| if(num < 1000) return num.toString(); | |
| const exp = Math.floor(Math.log(num)/ Math.log(1000)); | |
| const minimized = Number((num / Math.pow(1000, exp)).toFixed(2)); | |
| return minimized+minimizeMap[exp-1]; | |
| } |