-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
26 lines (23 loc) · 686 Bytes
/
app.js
File metadata and controls
26 lines (23 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* Updates the clock element with the current time.
*
* @function updateClock
* @returns {void}
*/
function updateClock() {
// Get the current date and time
const now = new Date();
// Format the hours, minutes, and seconds with leading zeros
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
// Update the clock element with the formatted time
clockElement.innerText = `${hours}:${minutes}:${seconds}`;
}
/**
* Calls the updateClock function every second.
*
* @function
* @returns {void}
*/
setInterval(updateClock, 1000);