This file contains hidden or 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 filterLists(list){ | |
| try{ | |
| let filteredList=list.filter(function(item, index){ | |
| return item.age >= 30 && item.age <= 40 | |
| }); | |
| let genderIndex=[] | |
| let groupedList=filteredList.reduce(function(accum, item, index){ | |
| let gIndex= genderIndex.indexOf(item.gender); | |
| if(gIndex>=0){ | |
| accum[gIndex].push(item); |
This file contains hidden or 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
| let persons=[ | |
| { name:"Jude", age:30 }, | |
| { name:"Lily", age:25 }, | |
| { name:"Mark", age:34 }, | |
| { name:"Luke", age:18 }, | |
| { name:"John", age:55 }, | |
| { name:"Jack", age:12 } | |
| ] | |
| sortedPersons=persons.sort((a, b)=> a.age - b.age) |