Skip to content

Instantly share code, notes, and snippets.

@hidakatsuya
Created April 20, 2011 03:08
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 hidakatsuya/930260 to your computer and use it in GitHub Desktop.
Save hidakatsuya/930260 to your computer and use it in GitHub Desktop.
Create number with delimitation on JavaScript
function numberWithDelimiter(n) {
n = String(n);
while(n != (n = n.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
return n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment