forked from Angiepmunoz/method-like-functions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
84 lines (74 loc) · 4.07 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
75
76
77
78
79
80
81
82
83
84
/**
* Appends an element to the end of an array. Do not use the push method.
* @param {Array[*]} array - an array of any kind of elements.
* @param {Array[*]} element - an element of any kind.
* @returns {number} the new length of the array.
*/
function myPushFunction(array, element) {}
/**
* Removes the last element of the array and returns the removed element, or undefined if the array is empty. Do not use the pop method.
* @param {Array[*]} array - an array of any kind of elements.
* @returns {*} - the removed element
*/
function myPopFunction(array) {}
/**
* Determines whether an array includes a specific value within its entries. Do not use the includes method.
* @param {Array[*]} array - an array of any kind of elements.
* @param {*} searchElement - an element of any type that you are searching for in the array.
* @param {number} [startIdx] - an optional index from which to start searching.
* @returns {boolean} returns true if the searchElement is found in the array and false if it is not.
*/
function myIncludesFunction(array, searchElement, startIdx) {}
/**
* Returns the first index in an array where a specified value is found. Do not use the indexOf method.
* @param {Array[*]} array - an array of any kind of elements.
* @param {*} searchElement - an element of any type that you are searching for in the array.
* @param {number} [startIdx] - an optional index from which to start searching.
* @returns {number} returns the index at which the searchElement is found, or -1 if it is not found.
*/
function myIndexOfFunction(array, searchElement, startIdx) {}
/**
* Returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified. Do not use the slice method.
* @param {Array[*]} array - an array of any kind of elements.
* @param {number} [startIdx] - an optional number representing the starting index of the extraction. The startIdx can be negative.
* @param {number} [endIdx] - an optional number representing the ending index of the extraction (non-inclusive). The endIdx can be negative.
* @returns {Array[*]} returns a new array containing the extracted elements.
*/
function mySliceFunction(array, startIdx, endIdx) {}
/**
* Creates and returns a new string by concatenating all of the elements in an array, separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator. Do not use the join method.
* @param {Array[*]} array - an array of any kind of elements
* @param {string} [separator] - an optional string to separate each pair of adjacent elements of the array. If no separator is specific the default separator should be a comma (",")
* @returns {string} returns the concatenated string.
*/
function myJoinFunction(array, separator) {}
/**
* Reverses the elements in the given array, returning the array. The first array element becomes the last, and the last array element becomes the first. Mutates the original array. Do not use the reverse method.
* @param {Array[*]} array - an array of any kind of elements
* @returns {Array[*]} returns a new array with the elements reversed.
*/
function myReverseFunction(array) {}
/**
* Adds an element to the front of the array. Do not use the unshift method.
* @param {Array[*]} array - an array of any kind of elements.
* @param {*} newElement - an element of any type to add to the front of the array.
* @returns {number} returns the new length of the array.
*/
function myUnshiftFunction(array, newElement) {}
/**
* Removes the first element of the array and returns the removed element, or undefined if the array is empty. Do not use the shift method.
* @param {Array[*]} array - an array of any kind of elements.
* @returns {*} - the removed element
*/
function myShiftFunction(array) {}
module.exports = {
myPushFunction,
myPopFunction,
myIncludesFunction,
myIndexOfFunction,
mySliceFunction,
myJoinFunction,
myReverseFunction,
myUnshiftFunction,
myShiftFunction,
};