Page 164 - Computer Software Application TP - Volume 1
P. 164

COMPUTER SOFTWARE APPLICATION - CITS




                 <script>
                 var greet = function(name)
                 {
                 // Inside the function, logging a greeting message to the console with the provided name

                 console.log(“Hello, “ + name + “!”);
                 };
                 // Calling the function with an argument “John”
                 greet(“John”); // Output: Hello, John!

                 </script>
                 </body>
                 </html>
              3  Save the program as a .html file
              4  Open the html file with a web browser

              5  Go to the browsers console tab and verify the output.














           II  Using Arrow Function
              1  Open the text editor
              2  Write the following codes
                 <html >
                 <head>
                 <title> </title>
                 </head>
                 <body>
                 <script>
                 const greet = () => {
                 console.log(“Hello!”);

                 };
                 greet(); // Call the function
                 </script>
                 </body>
                 </html>

              3  Save the program as a .html file
              4  Open the html file with a web browser
              5  Go to the browsers console tab and verify the output.





                                                           149
 CITS : IT & ITES - Computer Software Application - Exercise 41  CITS : IT & ITES - Computer Software Application - Exercise 41
   159   160   161   162   163   164   165   166   167   168   169