Posted By

troynt on 05/09/10


Tagged

numbers


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dipser


Commafy


 / Published in: JavaScript
 

  1. // "1234567".commafy() returns "1,234,567"
  2. String.prototype.commafy = function() {
  3. return this.replace(/(.)(?=(.{3})+$)/g,"$1,")
  4. }

Report this snippet  

You need to login to post a comment.