This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filterAndGroup(people){ | |
//Add empty object to offset it | |
people.unshift({}) | |
//Use reduce method to loop through and sort | |
return people.reduce((grouped,obj) => { | |
//Gender of current item | |
const gender = obj.gender; | |
//Check age requirement | |
if(obj.age >= 30 && obj.age <= 40) | |
{ |