All Challenges

Nested Comment Thread Reply Box

ReactHardAtlassianRedditDisqus
45:00

Problem Brief

Build a recursive comment thread where users can post top-level comments and reply cleanly to any nested comment node.

Requirements

  • Post new root comments via `[data-testid="root-input"]` and `[data-testid="post-root"]`.
  • Render `.comment-node` cards inside `[data-testid="thread-root"]`.
  • Clicking `.reply-trigger` inside any `.comment-node` opens an inline `.reply-input` + `.reply-submit` box.
  • Submitting a reply nests a child `.comment-node` recursively under that comment.
Progressive Hints (1)
  • Store a tree `{ id, text, replies: CommentNode[] }` and write a small recursive `addReply(nodes, targetId, text)` helper.
Reference Solution

Stuck? Load the verified reference code into your editor.

Automated Test Suite

5 Test Cases Ready
  • Renders initial seed comment nodeShows 1 .comment-node initially
  • Posts new top-level commentTyping in root-input and clicking post-root renders 2nd node
  • Clicking Reply opens inline reply inputReveals .reply-input and .reply-submit inside target comment
  • Submitting reply appends nested child comment nodeChild .comment-node appears inside parent .comment-node
  • Supports multi-level nested reply (depth 2)Replying to a nested reply creates a level-2 child cleanly
solution.html
Live Sandboxed Previewiframe sandbox
Starter template loaded — add your <script> logic in the editor (or open Reference Solution) to make the widget interactive.