Created
March 20, 2016 08:03
-
-
Save rutcreate/03ff3f9bd5f414465322 to your computer and use it in GitHub Desktop.
JavaScript: Integer and Float validation
This file contains hidden or 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 isInt(n){ | |
return Number(n).toString() === n.toString() && n % 1 === 0; | |
} | |
function isFloat(n){ | |
return Number(n).toString() === n.toString() && n % 1 !== 0; | |
} |
Author
rutcreate
commented
Mar 20, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment