Skip to content

Instantly share code, notes, and snippets.

@aleclarson
Created March 17, 2016 00:12
Show Gist options
  • Save aleclarson/63b616a73b0ecd4e133d to your computer and use it in GitHub Desktop.
Save aleclarson/63b616a73b0ecd4e133d to your computer and use it in GitHub Desktop.
Count the number of digits (before the decimal) in a number
module.exports = (n) ->
n = Math.abs n
return 1 if n < 1
count = 0
while n >= 1
count += 1
n /= 10
count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment