Skip to content

Instantly share code, notes, and snippets.

@lcds90
Created October 2, 2021 05:01
Show Gist options
  • Save lcds90/d91e2749c2ba769bea1e94ffcc5c1408 to your computer and use it in GitHub Desktop.
Save lcds90/d91e2749c2ba769bea1e94ffcc5c1408 to your computer and use it in GitHub Desktop.
Welcome Greeting Message based on time
const welcomeMessage = () => {
const hour = new Date().getHours();
const message = {
morning: 'Bom dia',
afternoon: 'Boa tarde',
evening: 'Boa noite',
default: 'Olá',
};
if (hour >= 6 && hour <= 12) return message.morning;
if (hour >= 12 && hour <= 18) return message.afternoon;
if (hour >= 6 && hour <= 23) return message.evening;
return message.default;
};
export default welcomeMessage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment