Skip to content

Instantly share code, notes, and snippets.

@Fernando74lr
Last active February 7, 2021 02:37
Show Gist options
  • Save Fernando74lr/5a6350e5d802a1ebebba16a1274b4332 to your computer and use it in GitHub Desktop.
Save Fernando74lr/5a6350e5d802a1ebebba16a1274b4332 to your computer and use it in GitHub Desktop.
// Gretting by the moment of the day
function getDayMoment() {
let hour = new Date().getHours();
if (hour < 12) return ['Good morning', '👋'];
if (hour >= 12 && hour < 18) return ['Good afternoon', '👋'];
if (hour >= 18 && hour < 20) return ['Good evening', '🌗'];
if (hour >= 20) return ['Good night', '🌙'];
}
@Fernando74lr
Copy link
Author

Small script to greet depending on the time of day with JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment