xxxxxxxxxx
Line 11 in the code is incorrect.
"if(isNaN(num1){" is missing the closing parentheses.
It should be "if(isNaN(num1)){" instead.
xxxxxxxxxx
// strict, matches only objects of type 'number'
// excluding Infinity and NaN.
function isNumber(n) {
return typeof n === 'number' && isFinite(n);
}
xxxxxxxxxx
// IsInteger
if (Number.isInteger(val)) {
// It is indeed a number
}
// isNaN (is not a number)
if (isNaN(val)) {
// It is not a number
}
// Another option is typeof which return a string
if (typeof(val) === 'number') {
// Guess what, it's a bloody number!
}