-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
74 lines (56 loc) · 1.84 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// 1. Find Highest Frequency (findHighestFreq)
//
// Goal: find the most frequent occurrence in an array
//
// Input: an array (<inputArr>) i.e. [2, 4, 9, 4, 2, 32, 4, 5, 2, 1]
//
// Output: most frequent occurrence i.e. '4' in the above example
//
// Note: if there is no winner, return 'null'
export function findHighestFreq(inputArr) {
/*<YOUR CODE HERE>*/
}
// 2. Get Property Array (getPropArr)
//
// Goal: return an array of values of a specific property from an array of objects
//
// Input: an array of objects (<objects>), and a property string (<field>) i.e.
//
// objects = [{id: 1, name: 'joe'}, {id: 2, name: 'tom'}, {id: 3, name: 'mike'}]
//
// field = 'name'
//
// Output: an array of values i.e. ['joe', 'tom', 'mike'] in the above example
//
// Note: if <objects> is undefined, return 'null'
export function getPropArr(objects, field) {
/*<YOUR CODE HERE>*/
}
// 3. Sort Object Array (sortObjArr):
//
// Goal: sort an object array in a particular order based on field value
//
// Input: an array of objects (<objects>), a property string (<field>), and an <order> i.e.
//
// 'asc' = ascending:
// A, B, C, D (strings / alphabetically)
// 1, 2, 3, 4 (numbers or counts / numerically)
//
// 'desc' = descending:
// D, C, B, A
// 4, 3, 2, 1
//
// Output: the initial array of <objects> sorted by <field> in the appropriate <order>
//
// Reference './tests/mockUsers.js' for the user data structures
//
// Note: should be able to sort objects based on the following fields:
//
// firstName (string / alphabetically)
// lastName (string / alphabetically)
// email (string / alphabetically)
// groups (count / numerically)
// age (number / numerically)
export function sortObjArr(objects, field, order) {
/*<YOUR CODE HERE>*/
}