Implement React check-in/out month dropdowns
Akuna CapitalSoftware Engineer · HR ScreenLast updated
This question evaluates front-end React skills including controlled components, state synchronization, interdependent input validation, keyboard accessibility/ARIA, and unit testing for UI behavior, and it sits in the Front-end/UI development domain (Other/Miscellaneous) with an emphasis on practical implementation rather than purely conceptual reasoning. It is commonly asked because interviewers use it to verify an engineer's ability to enforce input constraints, integrate dropdowns with existing form state and submission flows, maintain accessibility with native controls, and provide test coverage for validation and disabled-option behavior.
You are given a React codebase for a hotel reservation page. Enhance the UI by adding two dropdown menus: one for Check-in month and one for Check-out month. Requirements: (
- Render the two month dropdowns integrated with the existing form; months should be selectable (e.g., January–December). (
- Enforce that the selected Check-out month is not earlier than the Check-in month; disable invalid options accordingly. (
- Disable months earlier than the current month for both dropdowns. (
- Keep the components controlled and synchronize selections with the provided state management (e.g., props/callbacks or context) so the booking form receives updates. (
- Validate on change and on submit; block submission and show inline errors if the constraint is violated. (
- Ensure keyboard accessibility and proper ARIA labels. (
- Add unit tests covering state updates, disabled options, and validation behavior.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.