forked from OleksiyRudenko/a-tiny-JS-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (48 loc) · 1.24 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
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/dmytro-botnarenko/a-tiny-JS-world
Web app: https://dmytro-botnarenko.github.io/a-tiny-JS-world/
*/
// ======== OBJECTS DEFINITIONS ========
// Define your objects here
const cat = {
species: 'cat',
name: 'Tom',
gender: 'male',
legs: 4,
hands: 0,
saying: 'miaow'
};
const dog = {
species: 'dog',
name: 'Spike',
gender: 'male',
legs: 4,
hands: 0,
saying: 'bow-wow!'
};
const man = {
species: 'human',
name: 'Jack',
gender: 'male',
legs: 2,
hands: 2,
saying: 'where is my slippers?'
};
const woman = {
species: 'human',
name: 'Jannie',
gender: 'female',
legs: 2,
hands: 2,
saying: 'Honey, I\'m home!'
};
const catWoman = {...woman};
catWoman.species = 'human-cat';
catWoman.name = 'Mell';
catWoman.saying = cat.saying;
// ======== OUTPUT ========
const creatures = [cat, dog, man, woman, catWoman];
const features = ['species', 'name', 'gender', 'legs', 'hands', 'saying'];
creatures.forEach((creature) => {print(features.map(feature => creature[feature]).join(' | '))})