constarr= [
{name:"2",age:18},
{name:"23",age:19},
{name:"2",age:19}
];
functiongroup(arr) {
varobj= {};
if(Array.isArray(arr)) {
for(vari=0;i
varname=arr[i].name;
if(nameinobj)obj[name].push(arr[i]);
elseobj[name] = [arr[i]];
varage=arr[i].age;
if(ageinobj)obj[age].push(arr[i]);
elseobj[age] = [arr[i]];
}
}
returnobj;
}
functionmax(obj) {
varret=0;
if(obj&&typeofobj==="object") {
for(varkeyinobj) {
varlength=obj[key].length;
if(length>ret)ret=length;
}
}
returnret;
}
console.log(max(group(arr))); // 2