Writing Your First JavaScript Program


Writing your first JavaScript program is an exciting step in your learning journey. It helps you understand how JavaScript code is written, saved, and executed.

In this lesson, you will learn how to create a simple JavaScript program and see its output. This is the first practical step toward becoming a real developer.

Where Can You Run JavaScript?

  • Inside a web browser  
  • In an HTML file using the <script> tag 
  • In the browser console 
  • On a server using Node.js  

For beginners, the easiest way is to run JavaScript in a browser.

This is your first JavaScript program. The console.log() function prints the message inside the browser console.

When you run this code, you will see the text appear in the developer tools console of your browser

In this example, JavaScript is written inside the <script> tag. When the page loads, the browser reads and executes the JavaScript code.

This shows how JavaScript works together with HTML to create dynamic web pages.

This example shows how JavaScript can interact with users by displaying a message box.

By writing and running your first programs, you build confidence and prepare yourself for more advanced topics like variables, conditions, and loops.