Created
October 2, 2021 05:01
-
-
Save lcds90/d91e2749c2ba769bea1e94ffcc5c1408 to your computer and use it in GitHub Desktop.
Welcome Greeting Message based on time
This file contains 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
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