title: Check If User Input Is Empty
body: <p>I'm having some trouble checking whether the input field is empty and when it is I want to revert it to the content in the h1 tag.</p>
  <pre><code>&lt;body&gt;
      &lt;h1&gt;Enter Your Username&lt;/h1&gt;
      &lt;input type=&quot;text&quot; id=&quot;username&quot; /&gt;
    &lt;/body&gt;
  
  const input = document.querySelector(&quot;input&quot;);
  const h1 = document.querySelector(&quot;h1&quot;);
  
  input.addEventListener(&quot;input&quot;, (e) =&gt; {
    h1.innerText = `Welcome ${input.value}`;
  });
  
  if (input.length === 0) {
    h1.innerText = &quot;Enter Your Username&quot;;
  }`enter code here`
  </code></pre>