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 2c96046 commit 048d459Copy full SHA for 048d459
project-10-digital-clock/main.js
@@ -5,4 +5,23 @@ const minuteEl = document.getElementById("minutes");
5
6
const secondEl = document.getElementById("seconds");
7
8
-const ampmEl = document.getElementById("am-pm");
+const ampmEl = document.getElementById("am-pm");
9
+
10
+function updateClock () {
11
+ let h = new Date().getHours();
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
+ hourEl.innerText = h;
22
+ minuteEl.innerText = m;
23
+ secondEl.innerText = s;
24
+ ampmEl.innerText = ampm;
25
+}
26
27
+updateClock();
0 commit comments