forked from jamesqquick/javascript-array-functions-practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsomeAndEvery.js
More file actions
50 lines (48 loc) · 1.39 KB
/
someAndEvery.js
File metadata and controls
50 lines (48 loc) · 1.39 KB
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
const characters = [
{
name: 'Luke Skywalker',
height: 172,
mass: 77,
eye_color: 'blue',
gender: 'male',
},
{
name: 'Darth Vader',
height: 202,
mass: 136,
eye_color: 'yellow',
gender: 'male',
},
{
name: 'Leia Organa',
height: 150,
mass: 49,
eye_color: 'brown',
gender: 'female',
},
{
name: 'Anakin Skywalker',
height: 188,
mass: 84,
eye_color: 'blue',
gender: 'male',
},
];
//***EVERY***
//1. Does every character have blue eyes?
console.log(characters.every(char=> char.eye_color == "blue"))
//2. Does every character have mass more than 40?
console.log(characters.every(char=> char.mass > 40))
//3. Is every character shorter than 200?
console.log(characters.every(char=> char.height < 200))
//4. Is every character male?
console.log(characters.every(char=> char.gender == "male"))
//***SOME***
//1. Is there at least one male character?
console.log(characters.some(char => char.gender=="male"))
//2. Is there at least one character with blue eyes?
console.log(characters.some(char => char.eye_color=="blue"))
//3. Is there at least one character taller than 210?
console.log(characters.some(char => char.mass>210))
//4. Is there at least one character that has mass less than 50?
console.log(characters.some(char => char.mass<50))