Medium
In a social media app, you need to implement a feature that processes user comments. What will the output be when this code runs?
1const comments = [2 { id: 1, text: "Great post!", likes: 5 },3 { id: 2, text: "Thanks!", likes: 3 },4 { id: 3, text: "Interesting", likes: 7 }5];67const processComments = comments.reduce((acc, comment) => {8 if (comment.likes > 4) {9 acc.popular.push(comment.text);10 } else {11 acc.regular.push(comment.text);12 }13 return acc;14}, { popular: [], regular: [] });1516console.log(processComments);