Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The display should use a 1 2 - hour clock and indicate whether it's AM or PM . The application looks like this: Digital clock

The display should use a 12-hour clock and indicate whether it's AM or PM. The application looks like
this:
Digital clock
Clock
12: 04:03PM
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.
In the JavaScript file, note that four functions are supplied. The function that you
can use to select elements. The padSingleDigit() function, that adds a leading zero to single digits
using a string method that you'll learn about in chapter 12. The start of a displayCurrentTime()
function. And the start of a DQMContentLoaded event handler.
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.
In the DQMContentLoaded event handler, code a timer that calls the displayCurrentTime() function
at 1 second intervals. Also, make sure that the current time showws as soon as the page loads.
head>
Digital clock
id=
Clock
:
:
id=
:body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
margin: 0 auto;
width: 400px;
border: 3px solid blue;
padding: 02em 1em;
}
h1{
color: blue;
}
margin-bottom: 1em;
}
label {
display: inline-block;
width: 11em;
text-align: right;
}
fieldset {
margin-bottom: 1em;
}
#seconds {
margin-right: 0.5em;
}
"use strict";
const $ = selector => document.querySelector(selector);
const padSingleDigit = num => num.toString().padStart(2,"0");
const displayCurrentTime
};
document.addEventListener("DOMContentLoaded",()=>{
// set initial clock display and then set interval timer to display
// new time every second. Don't store timer object because it
// won't be needed - clock will just run.
});
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Power Of Numbers In Health Care A Students Journey In Data Analysis

Authors: Kaiden

1st Edition

8119747887, 978-8119747887

More Books

Students also viewed these Databases questions

Question

Distinguish between hearing and listening.

Answered: 1 week ago

Question

Use your voice effectively.

Answered: 1 week ago