Created
September 22, 2018 10:36
-
-
Save nkint/f84b3a955f4726b915e896f1bf1352b0 to your computer and use it in GitHub Desktop.
commatize millions number
This file contains hidden or 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
// taken actually from https://github.com/adamwdraper/Numeral-js/blob/master/src/numeral.js#L241 | |
function commatizeMillions(number, lang) { | |
const str = (number).toFixed(0).toString() | |
const separator = lang === ITA ? '.' : ',' | |
const out = str.replace(/(\d)(?=(\d{3})+(?!\d))/g, `$1${separator}`) | |
return out | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment