Created
February 16, 2021 09:49
-
-
Save ChukwuEmekaAjah/1f1cd23bd01078cdc6711b86b08df76d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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