Skip to content

Instantly share code, notes, and snippets.

@nkint
Created September 22, 2018 10:36
Show Gist options
  • Save nkint/f84b3a955f4726b915e896f1bf1352b0 to your computer and use it in GitHub Desktop.
Save nkint/f84b3a955f4726b915e896f1bf1352b0 to your computer and use it in GitHub Desktop.
commatize millions number
// 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