So I am a beginner at Javascript so please help me understand this!
I was just testing out different things with if/else and prompt(), and when I wrote the codes below:
let ask = Number(prompt("Type a number"));
if (ask != NaN) {
alert(`You typed ${ask}`);
} else {
alert("You typed a word")
}
so the code is working well until I type in a word. when I type a number (for instance: 12) it shows "You type 12" but when I typed a word (for instance "cat"), it shows "You typed NaN". but why? I know "cat" is a NaN but why is it not showing the else statement? (You typed a word).
please help!