-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path01_objects.js
More file actions
70 lines (61 loc) · 1.86 KB
/
Copy path01_objects.js
File metadata and controls
70 lines (61 loc) · 1.86 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
/**
These exercises aim to get you familiar with object syntax. Hopefully it doesn't trigger
highschool biology flashbacks.
*/
// You can think of an object like a python dictionary or tree
// They usually have lots of deeply nested data
const TreeOfLife = {
// Objects can contain basic data types ...
rank: 'domain',
archae: 'archaebacteria',
bacteria: 'eubacteria',
// ... but they can also contain nested objects, arrays, functions, or anything else
eukarya: {
rank: 'kingdom',
plantae: ['my succulent', 'tomatoes', 'big trees'],
animalia: {
rank: 'phylum',
birds: 'work for the bourgeoisie.',
humans: ['you', 'me', 'us', 'them', 'everyone!'],
},
fungi: {
guy: "he's fun",
},
protista: 'What even is this?',
},
// The best domain's key
bestDomain: 'archae',
}
//TODO -- Write a function which returns the domain "archae"
const getArchae = () => {}
// TODO -- Write a function which returns the array of humans
const getHumans = () => {}
// TODO -- Write a function which adds a name to the array of humans
const addHuman = (name) => {}
// TODO -- Write a fuction which returns the data representing the "bestDomain"
const getBestDomain = () => {}
// TODO -- Write a function which sets the best domain to "eukarya" and then returns the "bestDomain"
const setGetBestDomain = () => {}
/**
TODO
Write a function using destructuring and object renaming which returns an array with all the ranks like:
(Don't hardcode it, pull it from the TreeOfLife)
[
'domain',
'kingdom',
'phylum',
]
*/
const getRanks = () => {}
// TODO -- Write a function which uses destructuring and the rest operator to return everything BUT the "eukarya"
const noEukaryotes = () => {}
module.exports = {
getArchae,
getHumans,
addHuman,
getBestDomain,
setGetBestDomain,
getRanks,
noEukaryotes,
TreeOfLife,
}