Skip to content

Instantly share code, notes, and snippets.

@ChukwuEmekaAjah
Created February 16, 2021 09:49
Show Gist options
  • Save ChukwuEmekaAjah/1f1cd23bd01078cdc6711b86b08df76d to your computer and use it in GitHub Desktop.
Save ChukwuEmekaAjah/1f1cd23bd01078cdc6711b86b08df76d to your computer and use it in GitHub Desktop.
let timeNow = new Date();
let currentHour = timeNow.getHours();
let count = 1;
let idk = null
function greet(){
if (count == 10){
clearInterval(idk);
}
if ((5 <= currentHour) && (currentHour <= 10)){
console.log("Good morning");
}else if ((12 <= currentHour) && (currentHour <= 16)){
console.log("Good afternoon");
}else if ((17 <= currentHour) && (currentHour <= 21)){
console.log("Good evening");
}else if ((22 <= currentHour) && (currentHour <= 4)){
console.log("Good night");
}
console.log(count);
count++;
}
idk = setInterval(greet, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment