forked from OleksiyRudenko/a-tiny-JS-world
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
75 lines (66 loc) · 1.47 KB
/
index.js
File metadata and controls
75 lines (66 loc) · 1.47 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
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
import { print } from "./js/lib.js";
/* Refer to https://github.com/OleksiyRudenko/a-tiny-JS-world for the task details
Complete the below for code reviewers" convenience:
Code repository: _put repo URL here_
Web app: _put project"s github pages URL here_
*/
// ======== OBJECTS DEFINITIONS ========
// Define your objects here
const dog = {
species: "dog",
name: "Rick",
gender: "male",
legs: 4,
hands: 0,
saying: "woof-woof!",
hair: "brown"
};
const cat = {
species: "cat",
name: "Morty",
gender: "female",
legs: 4,
hands: 0,
saying: "mew-mew!",
hair: "grey"
};
const man = {
species: "human",
name: "Greg",
gender: "male",
legs: 2,
hands: 2,
saying: "Hello, world!",
hair: "blond"
};
const woman = {
species: "human",
name: "Greg",
gender: "female",
legs: 2,
hands: 2,
saying: "Hello, world!",
hair: "red"
};
const catWomen = {
species: "superhuman",
name: "Belatris",
gender: "female",
legs: 2,
hands: 2,
saying: cat.saying,
hair: "brown"
};
const inhabitantAttributes = [
'species', 'name', 'gender', 'legs', 'hands', 'saying', 'hair'
];
const inhabitantList = [man, woman, cat, dog, catWomen];
// ======== OUTPUT ========
function showInformation(somebody) {
let result = [];
inhabitantAttributes.map(attribute => {
result.push(somebody[attribute]);
});
return result.join('; ');
}
inhabitantList.forEach(inhabitant => print(showInformation(inhabitant)));