let username;
document.getElementById("mySubmit").onclick= function(){
username= document.getElementById("myText").value;
document.getElementById("myH1").textContent= `Hello ${username}`
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="4style.css">
</head>
<body>
<script src="4userinput.js"></script>
<h1 id="myH1">Welcome</h1>
<label>user name:</label>
<input id="myText">
<br>
<br>
<button id="mySubmit">Submit</button>
</body>
</html>
Upon executing the code, an error was triggered: 4userinput.js:10 Uncaught TypeError: Cannot set properties of null (setting 'onclick')
I am seeking assistance to resolve this issue. Interestingly, my code worked flawlessly in the StackOverflow snippet environment.