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.
<body>
<h1>Enter Your Username</h1>
<input type="text" id="username" />
</body>
const input = document.querySelector("input");
const h1 = document.querySelector("h1");
input.addEventListener("input", (e) => {
h1.innerText = `Welcome ${input.value}`;
});
if (input.length === 0) {
h1.innerText = "Enter Your Username";
}`enter code here`