forked from TrainingByPackt/Professional-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise51.js
More file actions
32 lines (28 loc) · 756 Bytes
/
Exercise51.js
File metadata and controls
32 lines (28 loc) · 756 Bytes
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
let profiles = [
'Michael Scott',
'Jim Halpert',
'Dwight Shrute',
'Random User',
'Hatsune Miku',
'Rin Kagamine'
];
let hasJim = profiles.includes('Jim Halpert');
console.log(hasJim);
profiles = [
{ name: 'Michael Scott', age: 42 },
{ name: 'Jim Halpert', age: 27},
{ name: 'Dwight Shrute', age: 37 },
{ name: 'Random User', age: 10 },
{ name: 'Hatsune Miku', age: 16 },
{ name: 'Rin Kagamine', age: 14 }
];
hasJim = profiles.includes({ name: 'Jim Halpert', age: 27});
console.log(hasJim);
hasJim = !!profiles.find((profile) => {
return profile.name === 'Jim Halpert';
}).length;
console.log(hasJim);
const adults = profiles.filter((profile) => {
return profile.age > 18;
});
console.log(adults);