-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathchallenges-1.js
200 lines (153 loc) · 6.01 KB
/
challenges-1.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
// ================================================================
// Titanic Dataset challenges!
// Your goal is to write some functions that will extract
// relevant data from the dataset.
// Write your code here in this file.
// *************************************
// Test your code by running: `npm test`
// *************************************
// Each of the functions below expects to receive the Titanic data
// as the parameter data. Your goal is to extract the relevant
// piece of information from the data and return it.
// =================================================================
// 1 ---------------------------------------------------------------
// Return the total number of passengers.
// Return a number.
function getTotalPassengers(data) {
return 0
}
// 2 ---------------------------------------------------------------
// Return the number of surviving passengers. A passenger survived
// if their survived property is "Yes".
// Return a number.
function getSurvivorCount(data) {
return 0
}
// 3 ---------------------------------------------------------------
// Return the number of passengers who did not survive. A passenger
// Return a number.
function getCasualityCount(data) {
return 0
}
// 4 ---------------------------------------------------------------
// Return the number of passengers in any class. This function
// takes the data and the passenger class a string. Fins all of the
// passengers whose pclass matches and return the count.
// Return a number
function countPassengersInClass(data, pclass) {
return 0
}
// 5 ---------------------------------------------------------------
// Return the number of survivors in a class. This function takes
// the data and passenger class. Return only passengers
function getSurvivorCountForClass(data, pclass) {
return 0
}
// 6 ---------------------------------------------------------------
// Return the number of passengers who did not survive in a class.
// This function takes the data and the passenger class and returns
// the number of passengers who did not survive for that class.
function getCasualityCountForClass(data, pclass) {
return 0
}
// 7 ---------------------------------------------------------------
// Return the age of the youngest passenger. You'll need to filter
// passenger data where the age is missing.
function getMinAge(data) {
return 0
}
// 8 ---------------------------------------------------------------
// Return the age of the oldest passenger.
function getMaxAge(data) {
return 0
}
// 9 ---------------------------------------------------------------
// Return the number of passengers that embarked at a given stop.
// Each passenger has a embarked property with a value of: S, C,
// or Q.
function getEmbarkedCount(data, embarked) {
return 0
}
// 10 ---------------------------------------------------------------
// Return the lowest fair paid by any passenger. The fare is missing
// for some passengers you'll need to filter this out!
function getMinFare(data) {
return 0
}
// 11 ---------------------------------------------------------------
// Return the highest fare paid by any passenger. Some of the
// passengers are missing data for fare.
function getMaxFare(data) {
return 0
}
// 12 ---------------------------------------------------------------
// Return the count of passengers by gender.
function getPassengersByGender(data, gender) {
return 0
}
// 13 ---------------------------------------------------------------
// Return the number of passengers who survived by gender.
function getSurvivorsByGender(data, gender) {
return 0
}
// 14 ---------------------------------------------------------------
// Return the number of passengers who did not survived by gender.
function getCasualitiesByGender(data, gender) {
return 0
}
// 15 --------------------------------------------------------------
// Return the total of all fares paid.
function getTotalFare(data) {
return 0
}
// 16 --------------------------------------------------------------
// Return the average fare paid.
function getAverageFare(data) {
return 0
}
// 17 --------------------------------------------------------------
// Return the median fare. The median is the value equal distance
// from the minimum and maximum values.
function getMedianFare(data) {
return 0
}
// 18 --------------------------------------------------------------
// Return the average age of all passengers.
function getAverageAge(data) {
return 0
}
// 19 --------------------------------------------------------------
// Return the median age from passengers.
function getMedianAge(data) {
return 0
}
// 20 --------------------------------------------------------------
//
function getAverageAgeByGender(data, gender) {
return 0
}
// --------------------------------------------------------------
// --------------------------------------------------------------
module.exports.getTotalPassengers = getTotalPassengers
module.exports.getSurvivorCount = getSurvivorCount
module.exports.getCasualityCount = getCasualityCount
module.exports.getUniqueValues = getUniqueValues
module.exports.countPassengersInClass = countPassengersInClass
module.exports.getSurvivorCountForClass = getSurvivorCountForClass
module.exports.getCasualityCountForClass = getCasualityCountForClass
module.exports.getMinAge = getMinAge
module.exports.getMaxAge = getMaxAge
module.exports.getEmbarkedCount = getEmbarkedCount
module.exports.getMaxFare = getMaxFare
module.exports.getMinFare = getMinFare
module.exports.getPassengersByGender = getPassengersByGender
module.exports.getSurvivorsByGender = getSurvivorsByGender
module.exports.getCasualitiesByGender = getCasualitiesByGender
module.exports.getSurvivorsByPClass = getSurvivorsByPClass
module.exports.getCasualitiesByPClass = getCasualitiesByPClass
module.exports.getTotalFare = getTotalFare
module.exports.getAverageFare = getAverageFare
module.exports.getMedianFare = getMedianFare
module.exports.getAverageAge = getAverageAge
module.exports.getMedianAge = getMedianAge
module.exports.getAverageAgeByGender = getAverageAgeByGender