From 5fa7eeb6965f8f97a75e29cd135e5af25b0a101e Mon Sep 17 00:00:00 2001 From: Sanket Banerjee Date: Thu, 27 Oct 2022 16:53:52 +0530 Subject: [PATCH] Added time-based greetings --- JS/index.js | 12 ++++++++++++ index.html | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/JS/index.js b/JS/index.js index 38ab17af..ad583431 100644 --- a/JS/index.js +++ b/JS/index.js @@ -40,3 +40,15 @@ async function fetchData() { setTimeout(() => { fetchData(); }, 1000); + + /* time-based greetings*/ + let container = document.querySelector(".container_greeting"); + let timeNow = new Date().getHours(); + let greeting = + timeNow >= 5 && timeNow < 12 + ? "Good Morning" + : timeNow >= 12 && timeNow < 18 + ? "Good Afternoon" + : "Good evening"; + container.innerHTML = `

${greeting} Hustler

`; +/* end */ diff --git a/index.html b/index.html index 5f508bfc..c213c6bf 100644 --- a/index.html +++ b/index.html @@ -201,7 +201,7 @@
- +
DEMO TEXT

CodeIN Community

CodeIN Community is a Community of more than 8,000+ Coding Enthusiasts, where we organize Open Source Programs, Hackathons, and Events on various emerging technologies and domains.