The following code can be placed anywhere in the html file:
<script> // The following code prints something different on a Thursday var d = new Date(); var n = d.getDay(); var weekday=new Array(7); weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday"; if (weekday[n]==="Thursday"){ document.write ("<p>Yes, today is <b>" + weekday[n] + "</b>, it's a Greenwich day!</p>"); }else{ document.write ("<p>No, today is <b>" + weekday[n] + "</b>, just an ordinary day.</p>"); } </script>
The code above prints a different message if today is Thursday. We use an if/else
statement to test a condition. Here we test to see if the day name is Thursday. If it is we print a special message. If it isn't Thursday we print something else.