Sorts an object array by gender using reduce - pretty nice √
let data = [
{name: "Raphel", gender: "male"},
{name: "Tom", gender: "male"},
{name: "Jerry", gender: "male"},
{name: "Dorry", gender: "female"},
{name: "Suzie", gender: "female"},
{name: "Dianna", gender: "female"},
{name: "Prem", gender: "male"},
];
let breakByGender = data.reduce((acc, item) => {
acc[item.gender].push(item);
return acc;
}, {male: [], female: []});
console.log(breakByGender);