Skip to content

Instantly share code, notes, and snippets.

@lucasdinonolte
Created September 27, 2012 15:31
Show Gist options
  • Save lucasdinonolte/3794646 to your computer and use it in GitHub Desktop.
Save lucasdinonolte/3794646 to your computer and use it in GitHub Desktop.
Coffee Script Number Formatting
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('')
@lucasdinonolte
Copy link
Author

Adds a decimal period to integer numbers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment