Programming in JavaScript – Week 5 Assignment
Starting with the downloadable assignment files, write the Javascript needed for the application. Use the book and lectures as a guide. In this exercise, you’ll create an application that displays the current time in hours, minutes, and seconds. The display should use a 12-hour clock and indicate whether it’s AM or PM. The application looks like this:

To convert the computer’s time from a 24-hour clock to a 12-hour clock, first check to see if the hours value is greater than 12. If so, subtract 12 from the hours value and set the AM/PM value to “PM”. Also, be aware that the hours value for midnight is 0.
1. Open the HTML and JavaScript files in the week 6 folder. Customize the interface title with your first and last name included.
2. In the JavaScript file, note that four functions are supplied. The $ function. The start of a displayCurrentTime() function. The padSingleDigit() function that adds a leading zero to single digits. And the start of an onload event handler.
3. In the displayCurrentTime() function, add code that uses the Date object to determine the current hour, minute, and second. Convert these values to a 12-hour clock, determine the AM/PM value, and display these values in the appropriate span tags.
4. In the onload event handler, code a timer that calls the displayCurrentTime() function at 1 second intervals. Also, make sure that the current time shows as soon as the page loads.
Create a document and paste in JS and/or HTML. Comment each code section with a detailed description of what it does. Zip all files for submission. Add a screenshot of the running application on your computer showing the time/date on your screen at the time of testing.
