Programming Code Center(PCC)
[JS]

(PCC)::[how-to-use-JavaScript-in-head-tag-and-run-program]::[js]

File Name : index.html

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>

<h2>JavaScript in Head</h2>

<p id="demo">A Paragraph.</p>

<button type="button" onclick="myFunction()">Try it</button>

</body>
</html> 

Output :

JavaScript in Head

A Paragraph.