I am trying to validate user input to see if they enter a number and show an error if they enter anything that's not a number.
here is the html element
<input type="text" id="user_input">
here is my javascript
let user_input = Number(document.querySelector("#user_input").value);
if (user_input == NaN) {
console.log("its not a number");
} else {
console.log("its a number");
}
Here, when I enter a string, it still says "its a number" on the console. Why is this happening?