Skip to content

Instantly share code, notes, and snippets.

@hayes
Last active August 29, 2015 14:02
Show Gist options
  • Save hayes/ea0d1d50b1272545ee62 to your computer and use it in GitHub Desktop.
Save hayes/ea0d1d50b1272545ee62 to your computer and use it in GitHub Desktop.
function add_commas(args, change) {
return function(val) {
var regex = /(\d+)(\d{3})/
val = val.toString()
while(regex.test(val)) {
val = val.replace(/(\d+)(\d{3})/, '$1,$2')
}
change(val)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment