console.log("Hello, World!");
To run this program, you will need to have a web browser that supports JavaScript.
- Open a text editor and copy the code above into a new file.
- Save the file with a
.jsextension, for examplemain.js. - Create an HTML file that includes the JavaScript file you just created. You can do this by adding a
<script>element to the HTML file and setting thesrcattribute to the path of the JavaScript file, like this:
<!DOCTYPE html>
<html>
<head>
<title>My JavaScript Program</title>
</head>
<body>
<script src="main.js"></script>
</body>
</html>
- Save the HTML file with a
.htmlextension, for exampleindex.html. - Open the HTML file in a web browser.
You should see the text “Hello, World!” printed to the console.
Leave a Reply