forked from OleksiyRudenko/a-tiny-JS-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (54 loc) · 1.3 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
import { print } from './js/lib.js';
const dog = {
hands: 0,
legs: 4,
name: 'Barbos',
gender: 'male',
phrase: 'Woof-woof!',
species: 'dog',
}
const cat = {
hands: 0,
legs: 4,
name: 'Sonya',
gender: 'female',
phrase: 'Meow!',
species: 'cat'
}
const woman = {
hands: 2,
legs: 2,
name: 'Eve',
gender: 'female',
phrase: 'Hello! Glad to see you!',
species: 'human'
}
const man = {
hands: 2,
legs: 2,
name: 'Adam',
gender: 'male',
phrase: 'Hi! Today is cool!',
species: 'human'
}
const catwoman = {
hands: 2,
legs: 2,
name: 'Selina',
gender: 'female',
species: 'human'
}
catwoman.phrase = cat.phrase;
const friendsList = [
{inhabitant: dog, friends: [woman, man]},
{inhabitant: cat, friends: [woman]},
{inhabitant: woman, friends: [dog, cat, man]},
{inhabitant: man, friends: [dog, woman]},
{inhabitant: catwoman, friends: [cat, man]}
]
friendsList.forEach(({inhabitant, friends}) =>
inhabitant.friends = friends.map(({name}) => name).join(', '))
const inhabitants = [dog, cat, woman, man, catwoman];
inhabitants.map(({species, name, gender, hands, legs, phrase, friends}) =>
[species, name, gender, hands, legs, phrase, friends].join('; '))
.forEach(message => print(message));