Created
November 24, 2018 20:05
-
-
Save blueelvis/07e681a2c471eac73d39aaf416c77c57 to your computer and use it in GitHub Desktop.
Use this to check if a string is really a number or not... Code is based in TypeScript
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 isNumeric(x:string,base:number=10):boolean { | |
const parsedInt = parseInt(x,base); | |
if (isNaN(parsedInt)) { | |
return false; | |
} else { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment