Created
February 8, 2014 14:13
-
-
Save pid/8884370 to your computer and use it in GitHub Desktop.
helper: convert value/string to an integer // don't use parseInt( n , 10)
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
function toInteger(n) { | |
n = Number(n); | |
return n < 0 ? Math.ceil(n) : Math.floor(n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment