I tried to check if the input entered by a user is a number or not with the code below. It didn't work.
var a = Number(prompt("Enter a number"));
if (a !== NaN) {
console.log("yes");
}
else {
console.log("no");
}
I tried printing the value of a when the input wasn't a number and the output was NaN. But still, this code doesn't work. I know I can use isNaN(), but why doesn't my code work? And is there some other way to check if the input is a number without using isNaN()?