First Code in Javascript

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

To run this program, you will need to have a web browser that supports JavaScript.

  1. Open a text editor and copy the code above into a new file.
  2. Save the file with a .js extension, for example main.js.
  3. 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 the src attribute 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>
  1. Save the HTML file with a .html extension, for example index.html.
  2. Open the HTML file in a web browser.

You should see the text “Hello, World!” printed to the console.

Leave a Comment

Your email address will not be published. Required fields are marked *