Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a React component that displays a greeting based on the current hour (e.g., 'Good Morning,' 'Good Afternoon').

Easy

Problem 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

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;