-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJSFoundationsProjectOne.js
82 lines (75 loc) · 1.81 KB
/
JSFoundationsProjectOne.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
/**
* Receives an array of numbers
* Filters out odd numbers
* Returns an array of the even numbers
*
* Example usage:
*
* filterEvens([1, 2, 3, 4, 5])
* returns [2, 4]
*
*/
function filterEvens(numbers) {
// your code goes here!
}
/**
* Receives an array of numbers
* Filters out even numbers
* Returns an array of the odd numbers
*
* Example usage:
*
* filterOdds([1, 2, 3, 4, 5])
* returns [1, 3, 5]
*
*/
function filterOdds(numbers) {
// your code goes here!
}
/**
* Receives an array of numbers
* Returns the sum of the odd numbers in that array
*
* Example usage:
*
* sumOdds([1, 2, 3, 4, 5])
* returns 9
*
*/
function sumOdds(numbers) {
// your code goes here!
}
/**
* Receives an array of names
* Makes the array into an array of pairs
* Order of names and pairs doesn't matter
* if the length of the array is odd, the last element is in an array on its own
* Returns the array of pairs
*
* Example usage:
*
* pairs(['Asis', 'Hamsa', 'Fawas', 'Mishmish', 'Hussein'])
* returns [['Mishmish', 'Fawas'], ['Asis', 'Hussein'], ['Hamsa']]
*
* pairs(['Aziz', 'Hamza', 'Fawaz', 'Mishmish'])
* returns [['Mishmish', 'Fawaz'], ['Aziz', 'Hamza']]
*
*/
function makePairs(names) {
// your code goes here!
}
/**************************************************
The following code runs the functions defined above
***************************************************/
let numbers = [153,67,9,34,7,67,342,7,34,8656,2,124,5,43];
let instructors = ["Hamza", "Mshary", "Aziz", "Hussein", "Fawaz"];
// uncomment the following lines to run and test your code.
// // filterEvens
// evens = filterEvens(numbers);
// console.log(evens);
// // sumOdds
// sum = sumOdds(numbers);
// console.log(sum);
// // makePairs
// let pairs = makePairs(instructors);
// console.log(pairs);