Created
May 23, 2014 21:32
-
-
Save naganowl/da938b7c0d8291233cbf to your computer and use it in GitHub Desktop.
Simple way to ensure an argument is a valid integer
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
# Convert `num` into a Number type. | |
parseNumber: (num) -> | |
parseNum = parseInt num, 10 | |
# Throw out strings and floats. | |
if parseNum is +num then parseNum else 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment