/* Group items on the basis of age of given array of object */
const people = [
{ name: "John", age: 21 },
{ name: "Max", age: 20 },
{ name: "Alexa", age: 20 }
];
const groupBy = (arr) => {
// Write code here
return;
};
console.log(groupBy(people));
// Output
/*
{
'20': [ { name: "Max", age: 20 }, { name: "Alexa", age: 20 } ],
'21': [ { name: "John", age: 21 } ]
}
*/
Where I can find this type of JS coding challenges for Interviews?
I want to practice this types of question which mostly asked in frontend interviews