Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nest = (items, id = null, link = 'childId') => {
- return items
- .filter(item => item[link] === id)
- .map(item => ({ ...item, children: nest(items, item._id) }))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement