Hi, welcome to new and final JavaScript practice project "portfolio website" for beginners along with explaination. You can copy the code by clicking the button just above the code. Read the explaiantion for better understanding.
let's get started with index.html file:
index.html
style.css:
index.js:
Here is the explaination:
The setDate() function is called to update the clock hands' rotation every second using setInterval(setDate, 1000). This means the function will be executed every 1000 milliseconds (1 second).
Inside the setDate() function, the current time is obtained using new Date().
The current seconds, minutes, and hours are extracted from the current time using getSeconds(), getMinutes(), and getHours() respectively.
Based on these values, the rotation degree for each clock hand is calculated. For example, the second's degree is calculated as (getSecond / 60) * 360 to represent the proportion of seconds passed in a minute.
The style.transform property is then updated for each clock hand, setting the rotation degree using template literals to dynamically update the CSS rotation. Finally, the setDate() function is initially called to set the initial position of the clock hands.
FINAL WORDS:
Thank you Don't forget to leave your feedback in the comment section. Follow front.end24 on instagram for more project ideas
index.html
style.css:
index.js:
Here is the explaination:
The setDate() function is called to update the clock hands' rotation every second using setInterval(setDate, 1000). This means the function will be executed every 1000 milliseconds (1 second).
Inside the setDate() function, the current time is obtained using new Date().
The current seconds, minutes, and hours are extracted from the current time using getSeconds(), getMinutes(), and getHours() respectively.
Based on these values, the rotation degree for each clock hand is calculated. For example, the second's degree is calculated as (getSecond / 60) * 360 to represent the proportion of seconds passed in a minute.
The style.transform property is then updated for each clock hand, setting the rotation degree using template literals to dynamically update the CSS rotation. Finally, the setDate() function is initially called to set the initial position of the clock hands.
FINAL WORDS:
Thank you Don't forget to leave your feedback in the comment section. Follow front.end24 on instagram for more project ideas

Great work mam
ReplyDelete