https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy
const people = [
{ name: "Max", age: 10 },
{ name: "Tim", age: 15 },
{ name: "Pip", age: 25 },
]
function adultsOnly({age}) {
if (age >= 18) {
return 'adult'
} else {
return 'minor'
}
}
const organized = Object.groupBy(people, adultsOnly)
console.log(organized)