First javaScript program

javaScript can be implemented on HTML pages in 2 ways:

  1. Inside HTML
  2. External .js File

javaScript is always enclosed within <script></script> tags.

Using alert() in javaScript

<!DOCTYPE html>
<html>

<head>
    <title>JavaScript Intro</title>
</head>

<body>
    <script>
        alert("Hello World");
    </script>
</body>

</html>

The alert function takes a string argument that is prompted on page loading.

Save the file as an HTML document and open the saved file in the browser to see the alert.

Leave a Comment

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