forked from HackYourFuture/Assignments
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
14 lines (12 loc) · 756 Bytes
/
index.js
File metadata and controls
14 lines (12 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*------------------------------------------------------------------------------
Full description at: https://github.com/HackYourFuture/Assignments/tree/main/2-Browsers/Week1#exercise-4-whats-the-time
1. Inside the `index.js`, complete the `addCurrentTime` to add the current time
to the webpage. Make sure it's written in the HH:MM:SS notation (hour, minute,
second). Use `setInterval()` to make sure the time stays current.
2. Have the function execute when it's loading in the browser.
------------------------------------------------------------------------------*/
function addCurrentTime() {
document.querySelector('time').textContent= new Date().toLocaleTimeString() ;
setInterval(addCurrentTime, 1000) ;
}
window.onload = addCurrentTime;