Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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('')
@lnolte

This comment has been minimized.

Copy link
Owner Author

commented Sep 27, 2012

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
You can’t perform that action at this time.