To add JavaScript to an HTML file, you can use the <script> tag. Place it either in the <head> or before the closing <body> tag. Example:
html
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Example</title>
<script>
console.log(“Hello, JavaScript!”);
</script>
</head>
<body>
<h1>My Web Page</h1>
</body>
</html>
Alternatively, you can link an external JavaScript file:
html
<script src=”script.js”></script>