DEV Community

Cover image for Greet your visitor
Mayank
Mayank

Posted on • Edited on

Greet your visitor

Greet your Visitors with Good Morning, Good Afternoon or Good Evening Message using JavaScript

Install using npm

npm install greet-visitor
Enter fullscreen mode Exit fullscreen mode

https://www.npmjs.com/package/greet-visitor

Sample Output - with emoji

Time Range Output
>= 3 - <= 12 🌞 Good morning
>= 12 - <= 17 🌞 Good afternoon
>= 17 - <= 20 πŸŒ“ Good evening
>= 20 - <= 24 πŸŒ’ Good night
>= 23 - <= 3 🌚 Oh! working late night

Configurable Default Options

{
    "emoji": true,
    "morning": "Good Morning",
    "noon": "Good Afternoon",
    "evening": "Good Evening",
    "night": "Good Night",
    "midnight": "Oh! working late night",
}
Enter fullscreen mode Exit fullscreen mode

Sample Code

var greet = require("greet-visitor");

greet();
// Based on system default time it will show different messages. as mentioned above
Enter fullscreen mode Exit fullscreen mode

Sample Code with Option Change

var greet = require("greet-visitor");

greet({emoji: false, noon: "Good noon !"});

// Output- at noon
"Good noon !"

// Output- in morning
"Good Morning"
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
corners2wall profile image
Corners 2 Wall

Good job dude
Image description

Collapse
 
mayank30 profile image
Mayank

Thanks alot..

Collapse
 
mayank30 profile image
Mayank

Guys i have upgrade the package. added mid night support

Collapse
 
mayank30 profile image
Mayank

for discussion on Product hunt - producthunt.com/discussions/greet-...