Created
September 27, 2012 15:31
-
-
Save lucasdinonolte/3794646 to your computer and use it in GitHub Desktop.
Coffee Script Number Formatting
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
addComma = (number) -> | |
number = new String number | |
chars = number.split('').reverse() | |
i = 0 | |
formatted = [] | |
for char in chars | |
if (i%3) is 0 and i isnt 0 | |
formatted.push('.') | |
formatted.push(char) | |
i++ | |
formatted.reverse().join('') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adds a decimal period to integer numbers