forked from OleksiyRudenko/a-tiny-JS-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
62 lines (56 loc) · 1.27 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
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: https://github.com/natata-tutorial/a-tiny-JS-world
Web app: https://natata-tutorial.github.io/a-tiny-JS-world/
*/
// ======== OBJECTS DEFINITIONS ========
// Define your objects here
const dog = {
species: 'dog',
name: 'Jack',
gender: 'male',
legs: 4,
hands: 0,
saying: 'woof-woof!'
};
const cat = {
species: 'cat',
name: 'Lili',
gender: 'female',
legs: 4,
hands: 0,
saying: 'meow!'
};
const woman = {
species: 'woman',
name: 'Nata',
gender: 'female',
legs: 2,
hands: 2,
saying: 'hi!'
};
const man = {
species: 'man',
name: 'Oleg',
gender: 'male',
legs: 2,
hands: 2,
saying: 'hey!',
friends: cat.name,
};
const catWoman = {
species: 'cat-woman',
name: 'Cat Nata',
gender: 'female',
legs: 4,
hands: 0,
saying: cat.saying,
};
// ======== OUTPUT ========
const population = [cat, dog, man, woman, catWoman];
const objFields = ["species", "name", "gender", "legs", "hands", "saying", "friends"];
population.map((soul) => {
print(objFields.map(key => key + ": " + soul[key] + "; ").join(" "));
}
);