forked from OleksiyRudenko/a-tiny-JS-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (58 loc) · 1.13 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
/* Refer to https://github.com/OleksiyRudenko/a-tiny-JS-world for the task details
Complete the below for code reviewers' convenience:
Code repository: https://github.com/kirill8210/a-tiny-JS-world
Web app: https://kirill8210.github.io/a-tiny-JS-world/
*/
// ======== OBJECTS DEFINITIONS ========
const dog = {
species: 'dog',
name: 'Toby',
gender: 'male',
legs: 4,
hands: 0,
saying: 'woof-woof!'
};
const cat = {
species: 'cat',
name: 'Tom',
gender: 'male',
legs: 4,
hands: 0,
saying: 'may-may!'
};
const woman = {
species: 'human',
name: 'Inna',
gender: 'female',
legs: 2,
hands: 2,
saying: 'Hello world!'
};
const man = {
species: 'human',
name: 'Kyryl',
gender: 'male',
legs: 2,
hands: 2,
saying: 'Hello world!'
};
// ======== OUTPUT ========
const inhabitants = [
dog,
cat,
woman,
man
];
const props = [
'species',
'name',
'gender',
'legs',
'hands',
'saying'
];
inhabitants.forEach(elem => {
print(
props.filter(prop => elem[prop] !== 0).map(prop => elem[prop]).join("; ")
);
});