how to change h1 text using javascript from node

JavaScript
<html>
<head></head>
<body>  
    <h1></h1>
<script src='test.js'></script>     
</body>
</html>
let h1 = document.getElementsByTagName('h1')[0];
h1.innerHTML = "Hello";
<!DOCTYPE html> 
<html> 
  
<head> 
    <title> 
        How to change the text of 
        a label using JavaScript ? 
    </title> 
</head> 
  
<body style="text-align:center;"> 
      
    <h1 style="color:green;"> 
        GeeksforGeeks 
    </h1> 
  
    <h4> 
        Click on the button to change 
        the text of a label 
    </h4> 
  
    <label id = "GFG"> 
        Welcome to GeeksforGeeks 
    </label> 
      
    <br> 
      
    <button onclick="myGeeks()"> 
        Click Here! 
    </button> 
  
    <script> 
        function myGeeks() { 
            document.getElementById('GFG').innerHTML 
                = 'A computer science portal for geeks'; 
        } 
    </script> 
</body> 
  
</html>       

Source

Also in JavaScript: