Write a React component that displays a greeting based on the current hour (e.g., 'Good Morning,' 'Good Afternoon').
EasyProblem Statement
Write a React component that displays a greeting based on the current hour (e.g., 'Good Morning,' 'Good Afternoon').
Sample Output
Good Morning, Good Afternoon, or Good Evening based on the time of day.
Limits
Time: 2s · Memory: 256 MB
Code Editor
Log in to submit00:00
Try your code in this preview. Submit marks it done.
import React from "react"; const Greeting = () => { const hour = new Date().getHours(); let greeting; // Determine the greeting based on the hour return ( // Display the appropriate greeting <></> ); }; export default Greeting;