Skip to content

Instantly share code, notes, and snippets.

@kpuputti
Last active December 15, 2015 02:19
Show Gist options
  • Save kpuputti/5186851 to your computer and use it in GitHub Desktop.
Save kpuputti/5186851 to your computer and use it in GitHub Desktop.
to NaN or not to NaN
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