/
index.js
93 lines (77 loc) · 2.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const fellas = [
{
name: "John Doe",
born: "1996",
placeOfBirth: "Elazig",
gender: "male",
expertise: "software",
salary: "100000",
},
{
name: "Taylor Man",
born: "1983",
placeOfBirth: "Bursa",
gender: "male",
expertise: "architecture",
salary: "60000",
},
{
name: "Brian Daylord",
born: "1995",
placeOfBirth: "Elazig",
gender: "male",
expertise: "software",
salary: "120000",
},
{
name: "Princess Tol",
born: "1999",
placeOfBirth: "Bursa",
gender: "female",
expertise: "medicine",
salary: "300000",
},
{
name: "Aegean Life",
born: "1994",
placeOfBirth: "Istanbul",
gender: "female",
expertise: "data",
salary: "120000",
},
];
//@@@@@@@@@@-MAP-@@@@@@@@@@
const allExpertises = fellas.map((f) => f.expertise);
uniqExpertises = [...new Set(allExpertises)];
// console.log(uniqExpertises);
const allBirthdates = fellas.map((f) => f.born);
// console.log(allBirthdates);
const smallerFeatures = fellas.map((f) => ({
name: f.name,
expertise: f.expertise,
}));
// console.log(smallerFeatures);
//@@@@@@@@@@-SOME-@@@@@@@@@@
const isFemaleExists = fellas.some((f) => f.gender === "female");
// console.log(isFemaleExists);
const isDoctorExists = fellas.some((f) => f.expertise === "medicine");
// console.log(isDoctorExists);
const isBillGatesExists = fellas.some((f) => f.salary > 10000000);
// console.log(isBillGatesExists);
//@@@@@@@@@@-FILTER-@@@@@@@@@@
const bigEarners = fellas.filter((f) => f.salary > 100000);
// console.log(bigEarners);
const olderFellas = fellas.filter((f) => f.born < 1995);
// console.log(olderFellas);
const ladies = fellas.filter((f) => f.gender === "female");
// console.log(ladies);
//@@@@@@@@@@-SORT-@@@@@@@@@@
const olderToYounger = fellas.sort((a, b) => a.born - b.born);
// console.log(olderToYounger);
const youngerToOlder = fellas.sort((b, a) => a.born - b.born);
// console.log(youngerToOlder);
const sortByExpertise = fellas.sort((a, b) => {
if (a.expertise < b.expertise) return -1;
return 1;
});
// console.log(sortByExpertise);