Skip to content

Commit 3146df0

Browse files
committed
ex4-whatsTheTime is modified
1 parent 265e9fd commit 3146df0

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎Week1/js-exercises/ex4-whatsTheTime.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<title>What's the time?</title>
1111
</head>
1212
<body>
13-
<p>Time: <span id="time"></span></p>
13+
1414

1515

1616
<script src="ex4-whatsTheTime.js"></script>

‎Week1/js-exercises/ex4-whatsTheTime.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313

1414
function displayCurrentTime() {
1515
// your code goes in here
16-
const time = new Date();
17-
document.getElementById('time').innerHTML = time.toLocaleTimeString();
16+
const time = new Date();
17+
const hours = time.getHours();
18+
const minutes = time.getMinutes();
19+
const seconds = time.getSeconds();
20+
const localTime = `${hours}:${minutes}:${seconds}`
21+
document.body.innerHTML = localTime
22+
1823
}
1924

2025
setInterval(displayCurrentTime, 1000);

0 commit comments

Comments
 (0)