Last active
December 15, 2015 02:19
-
-
Save kpuputti/5186851 to your computer and use it in GitHub Desktop.
to NaN or not to NaN
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 canHazInt(s) { | |
var n = parseInt(s, 10); | |
if (!isNaN(n)) { | |
return n; | |
} else { | |
throw new Error('no can do'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment