-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy patharrayFunctions.js
More file actions
60 lines (56 loc) · 1.63 KB
/
arrayFunctions.js
File metadata and controls
60 lines (56 loc) · 1.63 KB
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
/**
* getOdds(numbers):
* - receives an array of numbers called `numbers`
* - filters the `numbers` array in order to...
* - returns an array of only ODD numbers.
*
* e.g.
* getOdds([1, 2, 3, 4, 5, 6, 7, 8, 9]) -> [1, 3, 5, 7, 9]
* getOdds([11, 35, 52, 14, 56, 601, 777, 888, 999]) -> [11, 35, 601, 777, 999]
*/
function getOdds(numbers) {
// Your code here
}
/**
* getEvens(numbers):
* - receives an array of numbers called `numbers`
* - filters the `numbers` array in order to...
* - returns an array of only EVEN numbers.
*
* e.g.
* getEvens([1, 2, 3, 4, 5, 6, 7, 8, 9]) -> [2, 4, 6, 8]
* getEvens([11, 35, 52, 14, 56, 601, 777, 888, 999]) -> [52, 14, 56, 888]
*/
function getEvens(numbers) {
// Your code here
}
/**
* getDuplicateCount(x, numbers):
* - receives a number `x`, and an array of numbers called `numbers`
* - returns the number of times `x` occurs in `numbers`.
*
* e.g.
* getDuplicateCount(1, [1, 2, 3, 1, 4, 5, 6, 1, 7, 8, 9, 10, 11, 1, 12, 13]) -> 4
* getDuplicateCount(52, [11, 35, 52, 14, 56, 601, 52, 777, 888, 999, 52]) -> 3
*/
function getDuplicateCount(x, numbers) {
// Your code here
}
/**
* youGottaCalmDown(s):
* - receives a string `s`
* - returns the string `s` with at most one exclamation mark (!) at the end.
*
* e.g.
* youGottaCalmDown("HI!!!!!!!!!!") -> "HI!"
* youGottaCalmDown("Taylor Schwifting!!!!!!!!!!!") -> "Taylor Shwifting!"
* youGottaCalmDown("Hellooooo") -> "Hellooooo"
*
* Hint:
* - Use string method .slice()
* - Use string method .endsWith()
*/
function youGottaCalmDown(s) {
// Your code here
}
module.exports = { getOdds, getEvens, getDuplicateCount, youGottaCalmDown };