-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathlevel2.js
264 lines (254 loc) · 5.79 KB
/
level2.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import test from 'tape'
import { map, filter, reduce, compose } from 'nanofp'
const clients = [
{
age: 22,
eyeColor: 'green',
name: {
firstName: 'Horne',
lastName: 'Hahn'
},
gender: 'male',
email: '[email protected]',
phone: '+1 (803) 528-3269',
address: {
street: '494 Bayview Place',
city: 'Chesterfield',
state: 'Nebraska',
zip: 84643
},
registered: '2014-04-13T12:10:25 +04:00'
},
{
age: 25,
eyeColor: 'green',
name: {
firstName: 'Rhodes',
lastName: 'Harvey'
},
gender: 'male',
email: '[email protected]',
phone: '+1 (975) 583-2319',
address: {
street: '705 Legion Street',
city: 'Herald',
state: 'Idaho',
zip: 63136
},
registered: '2015-03-24T11:02:46 +04:00'
},
{
age: 40,
eyeColor: 'green',
name: {
firstName: 'Concetta',
lastName: 'Talley'
},
gender: 'female',
email: '[email protected]',
phone: '+1 (807) 538-2667',
address: {
street: '7245 3rd Ave',
city: 'Pickens',
state: 'South Carolina',
zip: 28745
},
registered: '2015-09-19T12:40:05 +04:00'
},
{
age: 26,
eyeColor: 'green',
name: {
firstName: 'Sandra',
lastName: 'Hogan'
},
gender: 'female',
email: '[email protected]',
phone: '+1 (987) 568-2357',
address: {
street: '332 Junius Street',
city: 'Cheyenne',
state: 'Wyoming',
zip: 37564
},
registered: '2015-03-18T11:57:49 +04:00'
},
{
age: 27,
eyeColor: 'blue',
name: {
firstName: 'Butler',
lastName: 'Flynn'
},
gender: 'male',
email: '[email protected]',
phone: '+1 (993) 588-3113',
address: {
street: '342 Gelston Avenue',
city: 'Asheville',
state: 'North Carolina',
zip: 28801
},
registered: '2017-10-02T06:08:32 +04:00'
},
{
age: 27,
eyeColor: 'blue',
name: {
firstName: 'Hurst',
lastName: 'Adkins'
},
gender: 'male',
email: '[email protected]',
phone: '+1 (955) 490-2739',
address: {
street: '874 Delvana Street',
city: 'Nanafilda',
state: 'Wyoming',
zip: 98647
},
registered: '2015-02-01T11:16:26 +05:00'
}
]
export default function() {
/* Level 2 - colors */
const ex1 =
'Use map to return a concatenated first and last name of each client.'
const exercise1 = _ => {
return []
}
const ex2 = 'Use filter to return clients from Wyoming'
const exercise2 = _ => {
return []
}
const ex3 = 'Use reduce to count the number of people with green eyes '
const exercise3 = _ => {
return 0
}
const ex4 = `Use map, filter and reduce with compose to return the full name (as a string) of the female from Wyoming. `
const exercise4 = _ => {
return null
}
const ex5 =
'Use map and filter to return the full address of the clients living in North Carolina'
const exercise5 = _ => {
return []
}
const ex6 = 'use filter to remove anyone over the age of 25'
const exercise6 = _ => {
return []
}
const ex7 =
'use reduce to count the number of males, age 22 - 27, who have green eyes'
const exercise7 = _ => {
return 0
}
/* tests to validate exercises go here */
test('test', assert => {
assert.plan(7)
assert.same(
exercise1(),
[
'Horne Hahn',
'Rhodes Harvey',
'Concetta Talley',
'Sandra Hogan',
'Butler Flynn',
'Hurst Adkins'
],
ex1
)
assert.same(
exercise2(),
[
{
age: 26,
eyeColor: 'green',
name: {
firstName: 'Sandra',
lastName: 'Hogan'
},
gender: 'female',
email: '[email protected]',
phone: '+1 (987) 568-2357',
address: {
street: '332 Junius Street',
city: 'Cheyenne',
state: 'Wyoming',
zip: 37564
},
registered: '2015-03-18T11:57:49 +04:00'
},
{
age: 27,
eyeColor: 'blue',
name: {
firstName: 'Hurst',
lastName: 'Adkins'
},
gender: 'male',
email: '[email protected]',
phone: '+1 (955) 490-2739',
address: {
street: '874 Delvana Street',
city: 'Nanafilda',
state: 'Wyoming',
zip: 98647
},
registered: '2015-02-01T11:16:26 +05:00'
}
],
ex2
)
assert.same(exercise3(), 4, ex3)
assert.equals(exercise4(), 'Sandra Hogan', ex4)
assert.same(
exercise5(),
['342 Gelston Avenue Asheville, North Carolina 28801'],
ex5
)
assert.same(
exercise6(),
[
{
age: 22,
eyeColor: 'green',
name: {
firstName: 'Horne',
lastName: 'Hahn'
},
gender: 'male',
email: '[email protected]',
phone: '+1 (803) 528-3269',
address: {
street: '494 Bayview Place',
city: 'Chesterfield',
state: 'Nebraska',
zip: 84643
},
registered: '2014-04-13T12:10:25 +04:00'
},
{
age: 25,
eyeColor: 'green',
name: {
firstName: 'Rhodes',
lastName: 'Harvey'
},
gender: 'male',
email: '[email protected]',
phone: '+1 (975) 583-2319',
address: {
street: '705 Legion Street',
city: 'Herald',
state: 'Idaho',
zip: 63136
},
registered: '2015-03-24T11:02:46 +04:00'
}
],
ex6
),
assert.equals(exercise7(), 2, ex7)
})
}