greeting for time of day

PHOTO EMBED

Mon Apr 11 2022 11:27:43 GMT+0000 (Coordinated Universal Time)

Saved by @shiva112 #react #js

function App() {
    const date = new Date()
    const hours = date.getHours()
    let timeOfDay
    
    if (hours < 12) {
        timeOfDay = "morning"
    } else if (hours >= 12 && hours < 17) {
        timeOfDay = "afternoon"
    } else {
        timeOfDay = "night"
    }
    return (
        <h1>Good {timeOfDay}!</h1>
    )
}
content_copyCOPY