Skip to content

Instantly share code, notes, and snippets.

View eatarandom's full-sized avatar

Dan Roberts eatarandom

  • East Flat Rock, NC
View GitHub Profile
@eatarandom
eatarandom / AddCommas.js
Created February 6, 2012 23:31
Convert a Number String to a Number String with commas
/**
* Converts "1000" to "1,000"
*/
String.prototype.addCommas = function() {
var s = this, c = this.length-3;
while(c>0){
s = s.substr(0,c)+','+s.substr(c,s.length-1);
c -= 3;
}
return s;