I'm creating a library and trying to send a string into the function and return it as a Number, while creating a conditional to determine if the string sent into the function is a number before I do the conversion.
var strNum = function(val){
if (!isNan(val)){
console.log('This is a string that can be converted')
parseInt(val)
return val
}else{
console.log ('This sting is not a "number"');
}
};
This is what I have but when debugging it I get an error of "ReferenceError: isNan is not defined if (val = !isNan(val)){" and I'm not sure why its isn't working!
Any thoughts?
isNaN()(note the second upper-case N), notisNan().