Visitar URL original
clock commit · wesbos/JavaScript30@c26e0a3 · GitHub
Skip to content

Commit c26e0a3

Browse files
author
Elise Kain
committed
clock commit
1 parent 2acab32 commit c26e0a3

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎02 - JS + CSS Clock/index-START.html‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,22 @@
7373

7474
function setDate() {
7575
const now = new Date();
76-
const seconds = now.getSeconds();
77-
const secondsDegrees = (seconds / 60) * 360
78-
console.log(secondsDegrees);
7976

77+
// second hand
78+
const seconds = now.getSeconds();
79+
const secondsDegrees = (seconds / 60) * 360;
8080
document.querySelector('.second-hand').style.transform = `rotate(${secondsDegrees + 90}deg)`;
81+
82+
// minute hand
83+
const minutes = now.getMinutes();
84+
const minutesDegrees = (minutes / 60) * 360;
85+
document.querySelector('.min-hand').style.transform = `rotate(${minutesDegrees + 90}deg)`;
86+
87+
// hour hand
88+
const hours = now.getHours();
89+
const hourDegrees = (hours / 12) * 360;
90+
document.querySelector('.hour-hand').style.transform = `rotate(${hourDegrees + 90}deg)`;
91+
8192
}
8293

8394
setInterval(setDate, 1000);

0 commit comments

Comments
 (0)