Created
July 17, 2013 09:51
-
-
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.
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
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