Skip to content

Instantly share code, notes, and snippets.

@goldnetonline
Created December 7, 2016 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goldnetonline/a8ef45dcf956b3b116fbed3dc80653d6 to your computer and use it in GitHub Desktop.
Save goldnetonline/a8ef45dcf956b3b116fbed3dc80653d6 to your computer and use it in GitHub Desktop.
Add Thousand Separator
function _addThousandSep(n){
var rx= /(\d+)(\d{3})/;
return String(n).replace(/^\d+/, function(w){
while(rx.test(w)){
w= w.replace(rx, '$1'+thousandSeparator+'$2');
}
return w;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment