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
00:00
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;
Expected Output
Good Morning, Good Afternoon, or Good Evening based on the time of day.