Use a tree data structure. Write a recursive render function. Each comment has reply, vote, and collapse handlers. Indent nested comments by depth. Handle reply (add a child), vote (update score), and collapse (toggle children).
How do I build nested comments in a machine coding interview?
More FAQs in Advanced Machine Coding Questions for Frontend Interviews
Star rating, nested comments (Reddit-style), tic-tac-toe, stopwatch, calculator, password strength meter, drag and drop list, tooltip, breadcrumb, and infinite scroll. These test recursion, game logic, APIs, and algorithms.
Create 5 star icons. On hover, highlight up to the hovered star. On click, lock the rating. Support half-stars with a clip or two separate icons. Add keyboard support (arrow keys to change, enter to select). Reset on mouse leave if not clicked.
Use the HTML Drag and Drop API: dragstart (store the dragged item index), dragover (prevent default to allow drop), drop (reorder the array). Update the data and re-render. Add visual feedback (highlight the drop target).
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.