forked from Make-School-Labs/map-filter-reduce-practice
-
Notifications
You must be signed in to change notification settings - Fork 1
/
challenge1.js
143 lines (106 loc) · 4.7 KB
/
challenge1.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
// ================================================================
// Array methods challenges!
// Your goal is to write some functions implementations of map/filter/reduce that will extract
// relevant data from an array.
// Write your code here in this file.
// *************************************
// Test your code by running: `npm test`
// *************************************
// Challenges 1, 3, 5 expect to receive a simple array of numbers [1, 2, 3, 4, 5] as the parameter data.
// The other challenges expect to receive parameter data from the people data set defined in people.js file
// Your goal is to extract the relevant
// piece of information from the data and return it.
// =================================================================
// 1 ---------------------------------------------------------------
// Map turn these numbers into strings
// Return an array with the numbers in the numbersArray as prices
function convertNumbersToPrices(nums) {
return [];
}
// 2 ---------------------------------------------------------------
// Map turn the balance in the peopleArray into currency notation
// Return an array of the balance field (people.balance) as a string in currency notation.
// For example 2276.38 => "$2,276.38"
function transformBalancetoCurrency(peopleArray) {
return [];
}
// 3 ---------------------------------------------------------------
// Filter out the odd numbers in the numbersArray leaving only the even numbers
// Return an array of even numbers
function filterOddNumbers(nums) {
return [];
}
// 4 ---------------------------------------------------------------
// Filter out the number of unregisterd people in the people data leaving only the registered people
// Return an array of registered People
function filterUnregisteredPeople(peopleArray) {
return [];
}
// 4 ---------------------------------------------------------------
// Filter out the number of unregisterd AND Unactive people in the people data
// Return an array of registered People who are active
function filterUnregisteredAndUnactivePeople(peopleArray) {
return [];
}
// 5 ---------------------------------------------------------------
// reduce(use the reduce method) an array of numbers to the sum of the number in the array
// Return a sum of the numbers in the array
function sumNumbers(nums) {
return 0;
}
// 6 ---------------------------------------------------------------
// Get(use the reduce method) the sum total of the ages for all the people in the people data
// Return a sum of the ages
function totalAge(peopleArray) {
return 0;
}
// 7 (stretch challenge) ---------------------------------------------------------------
// Return the number of the person with the highest balance
// Return an object containing the person's name and their balance e.g. {name: "Amy JJll", balance: 3872.67 }
function highestBalanceHolder(peopleArray) {
return {}
}
// 8 (Stretch Challenge) ---------------------------------------------------------------
// Return the number of times a particular eyeColor occurs in the people data set
// Return an object containing the eyeColor and number of times it occurs e.g {'blue': 2, 'brown': 3, 'green':0}
function countInstancesofEyeColor(peopleArray) {
return {}
}
// 9 (Stretch Challenge) ---------------------------------------------------------------
// Return an array containing the names of every REGISTERED WOMEN in the people data
function registeredWomen(peopleArray) {
return [];
}
// 10 (Stretch Challenge) ---------------------------------------------------------------
// Return the sum total of the balance for all REGISTERED and ACTIVE MEN in the people data
// Return your sum total in dollar currency notation e.g. $2,458.32
function totalBalanceRegandActiveMen(peopleArray) {
return '';
}
// 11 (Stretch Challenge) ---------------------------------------------------------------
// Return the sum total of the balance for all REGISTERED and ACTIVE WOMEN in the people data
// Return your sum total in dollar currency notation e.g. $2,458.32
function totalBalanceRegandActiveWomen(peopleArray) {
return '';
}
// 11 (Stretch Challenge) ---------------------------------------------------------------
// Return the sum total of the balance for everyone between the age of 35 and 40(people who are 35 and 40 excluded)
// Return your sum total in dollar currency notation e.g. $2,458.32
function totalBalanceAge35_40(peopleArray) {
return '';
}
module.exports = {
convertNumbersToPrices,
transformBalancetoCurrency,
filterOddNumbers,
filterUnregisteredPeople,
filterUnregisteredAndUnactivePeople,
sumNumbers,
totalAge,
highestBalanceHolder,
countInstancesofEyeColor,
registeredWomen,
totalBalanceRegandActiveMen,
totalBalanceRegandActiveWomen,
totalBalanceAge35_40
}