Skip to content

Instantly share code, notes, and snippets.

@piksel
Created July 17, 2013 09:51
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 piksel/6019242 to your computer and use it in GitHub Desktop.
Save piksel/6019242 to your computer and use it in GitHub Desktop.
Function for pretty-printing integers, placing spaces every third digit from the end.
var _f = function(i){
var s = new String(i);
var r = '';
for(c = s.length-1; c >= 0; c--){
r = s[c] + r
if(c !== 0 && (s.length-c) % 3 === 0) r = ' ' + r
}
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment