title: How to trigger an onclick function in js only if input field is not empty?
body: <p>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.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const input  =  document.querySelector("#input");
  
  
  function myFunc(){
  let name = input.value;
  if(name==null){
  alert("PLEASE ENTER YOUR NAME")
  } else{
  alert('Hello'+' '+name);
  }
  };</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
   
    
    &lt;input placeholder="Enter your name" id="input"&gt;
    &lt;button id="btn" onclick="myFunc()"&gt;Click me!&lt;/button&gt;
    
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>