Last active
February 4, 2017 10:04
-
-
Save namomo/ed9aa19bbcd95bc226df002fbbaea07e to your computer and use it in GitHub Desktop.
This file contains 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
function addComma(val) | |
{ | |
if (val === undefined) return '0'; | |
var reg = /(^[+-]?\d+)(\d{3})/; | |
val += ''; | |
while(reg.test(val)) { | |
val = val.replace(reg, '$1' + ',' + '$2'); | |
} | |
return val; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment