We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 048d459 commit 70e564aCopy full SHA for 70e564a
project-10-digital-clock/main.js
@@ -12,16 +12,24 @@ function updateClock () {
12
let m = new Date().getMinutes();
13
let s = new Date().getSeconds();
14
let ampm = "AM";
15
-
+
16
if (h > 12) {
17
h = h - 12;
18
ampm = "PM";
19
}
20
21
+ h = h < 10 ? "0" + h : h;
22
+ m = m < 10 ? "0" + m : m;
23
+ s = s < 10 ? "0" + s : s;
24
25
hourEl.innerText = h;
26
minuteEl.innerText = m;
27
secondEl.innerText = s;
28
ampmEl.innerText = ampm;
29
30
+ setTimeout(()=>{
31
+ updateClock();
32
+ }, 1000);
33
34
35
updateClock();
0 commit comments