Script:

  1. <html>
  2. <head>
  3. <title>JavaScript</title>
  4. </head>
  5. <body>
  6. <p> Today </p>
  7. <SCRIPT LANGUAGE=”JavaScript”>
  8. var today=new Date();
  9. write(“Today”);
  10. var todaysNum = today.getDay();
  11. var todaysName = dayName(todaysNum);
  12. write(todaysName);
  13. function dayName(day)
  14. {
  15. var names= new Array(7);
  16. names[0]= “Sunday”;
  17. names[1]= “Monday”;
  18. names[2]= “Tuesday”;
  19. names[3]= “Wednesday”;
  20. names[4]= “Thursday”;
  21. names[5]= “Friday”;
  22. names[6]= “Saturday”;
  23. return names[day];
  24. }
  25. </Script>
  26. </body>
  27. </html>

Explain of Script:

  • Line number 1 is a start is a html tag.
  • Line number 2 is a start is a head tag.
  • Line number 3 is a title tag. This page title is “JavaScript”.
  • Line number 4 is a close head tag.
  • Line number 5 start body tag.
  • Line number 6 write message “Today”
  • Line number 7 start JavaScript tag.
  • Line number 8 call new data.
  • Line number 9 write “Today” Message
  • Line number 10 is today.getDay(); function Call.
  • Line number 11 is var todaysName = dayName(todaysNum).
  • Line number 12 is write todaysName.
  • Line number 13 is getName(day)
  • Line number 14 uses “{”
  • Line number 15 is 7 array declare
  • Line number 16 is declare array [0]= “Sunday”.
  • Line number 17 is declare array [1]= ” Monday “.
  • Line number 18 is declare array [2]= ” Tuesday “.
  • Line number 19 is declare array [3]= ” Wednesday “.
  • Line number 20 is declare array [4]= ” Thursday “.
  • Line number 21 is declare array [5]= ” Friday “.
  • Line number 22 is declare array [6]= ” Saturday “.
  • Line number 23 is return function names[day].
  • Line number 24 is End “}”
  • Line number 25 is a closed JavaScript tag.
  • Line number 26 is a close body tag.
  • Line number 27 is a close html tag.

Leave a Reply

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