-
Notifications
You must be signed in to change notification settings - Fork 4
/
simpleSearch.js
21 lines (18 loc) · 903 Bytes
/
simpleSearch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const persons = [
{ name: 'Pedro', gender: 'male', address: 'Rua Augusta' },
{ name: 'Gabriella', gender: 'female', address: 'Jardim Ângela' },
{ name: 'Gabriel', gender: 'male', address: 'Jardim Ângela' },
{ name: 'Gabriela', gender: 'female', address: 'Capão Redondo' },
{ name: 'Sandro', gender: 'male', address: 'Capão Redondo' },
{ name: 'Tomás', gender: 'other', address: 'Jardim Ângela' },
{ name: 'Jack', gender: 'male', address: 'Capão Redondo' },
{ name: 'Gabrielle', gender: 'female', address: 'Jardim Ângela' }
]
// What if I want just females from Jardim Ângela and I typed: "Ga" on the search..
const wantedPersons = persons
.filter(person => person.gender.toLowerCase() === 'female')
.filter(
person => person.address.toLowerCase() === 'Jardim Ângela'.toLowerCase()
)
.filter(ga => ga.name.toLowerCase().includes('ga'))
console.log(wantedPersons)