-
Notifications
You must be signed in to change notification settings - Fork 249
/
Copy patharrayFunctions.js
83 lines (78 loc) · 2.1 KB
/
arrayFunctions.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
/**
* isArrayLengthOdd(numbers):
* - receives array `numbers`
* - returns true if array has an odd number of elements
* - returns false otherwise
*
* e.g.
* isArrayLengthOdd([1, 2, 3]) -> true
* isArrayLengthOdd([1, 2, 3, 4]) -> flase
*/
function isArrayLengthOdd(numbers) {
// Your code here
}
/**
* isArrayLengthEven(numbers):
* - receives array `numbers`
* - returns true if array has an even number of elements
* - returns false otherwise
*
* e.g.
* isArrayLengthEven([1, 2, 3]) -> false
* isArrayLengthEven([1, 2, 3, 4]) -> true
*/
function isArrayLengthEven(numbers) {
// Your code here
}
/**
* addLailaToArray(instructors):
* - receives array `instructors`
* - returns a new array that's a copy of array `instructors` with additional string "Laila"
*
* e.g.
* addLailaToArray(["Mshary", "Hasan"]) -> ["Mshary", "Hasan", "Laila"]
*/
function addLailaToArray(instructors) {
// Your code here
}
/**
* eliminateTeam(teams):
* - receives array `teams`
* - removes the last element from the array and return it
*
* e.g.
* eliminateTeam(["Brazil", "Germany", "Italy"]) -> "Italy"
*/
function eliminateTeam(teams) {
// Your code here
}
/**
* secondHalfOfArrayIfItIsEven(fruits):
* - receives array `fruits`
* - returns a new array that's the second half of the original array if it has an even number of elements
* - returns an empty array if it has an odd number of elements
*
* e.g.
* secondHalfOfArrayIfItIsEven(["apple", "orange", "banana", "kiwi"]) -> ["banana", "kiwi"]
* secondHalfOfArrayIfItIsEven(["apple", "orange", "banana", "kiwi", "blueberry"]) -> []
*/
function secondHalfOfArrayIfItIsEven(fruits) {
// Your code here
}
/**
* youGottaCalmDown(shout):
* - receives a string `shout`
* - returns the string `shout` with at most one exclamation mark (!) at the end.
*
* e.g.
* youGottaCalmDown("HI!!!!!!!!!!") -> "HI!"
* youGottaCalmDown("Taylor Schwifting!!!!!!!!!!!") -> "Taylor Shwifting!"
* youGottaCalmDown("Hellooooo") -> "Hellooooo"
*
* Hint:
* - Use number method .indexOf()
* - Use string method .slice()
*/
function youGottaCalmDown(shout) {
// Your code here
}