Here, I want the function to trigger only if i have typed something in the input field. If it's empty I want to alert that it can't be empty. I tried if else condition but it doesn't help. I even tried using typeof but no matter what the type is string.
const input = document.querySelector("#input");
function myFunc(){
let name = input.value;
if(name==null){
alert("PLEASE ENTER YOUR NAME")
} else{
alert('Hello'+' '+name);
}
};
<body>
<input placeholder="Enter your name" id="input">
<button id="btn" onclick="myFunc()">Click me!</button>
</body>