Grouping Users by City with JavaScript Array Methods

Common JavaScript Interview Question 🧠 💡 Scenario: You have an array of users: const users = [ { name: "Mohit", city: "Delhi" }, { name: "Amit", city: "Delhi" }, { name: "Rohit", city: "Noida" } ]; The interviewer asks: “How would you group these users by their city using JavaScript?” 👀 Simple-looking, but it tests: • Mastery of array methods • Understanding of reduce and object manipulation • Problem-solving mindset for real-world data 💡 Tip: Questions like this aren’t about memorizing syntax. They’re about how you think about transforming data efficiently 🚀 #JavaScript #JSInterview #FullStackInterview #CodingInterview #WebDevelopment #MERNStack #ProblemSolving #FrontendDeveloper

many approches are there but using map data sturucture also do best way

Like
Reply

To view or add a comment, sign in

Explore content categories