Put in order · Vibe coding with Claude Code course · Module 5: Reddit clone
Sorting: buildCommentTree step by step
Order the steps of the buildCommentTree function from the lesson:
Items to put in order
- Attach the node to its parent's replies or add it to the roots
- Create an empty map of nodes (Map)
- Go through the nodes a second time
- Return the roots
- For every comment store in the map a copy with an empty replies array
You can check the correct answer by solving this task in the CodeWorlds game.