run javascript in html code example

Example 1: javascript hello world

console.log("Hello World!");

Example 2: calling javascript file in html

<script type="text/javascript" src="yourfile.js"></script>

Example 3: print hello world in javascript

console.log("Hello, World!");

console.error("Error, World!"); // For errors

console.warn("Warning, World!"); // For warnings

console.clear(); // To clear the console

Example 4: how to enter javascript in html

<script type="text/javascript">
  alert("This alert box was called with the onload event");
</script>

Example 5: call js script in html

<script src="file1.js" type="text/javascript"></script> 
<script src="file2.js" type="text/javascript"></script>