Some challenges to practice using arrays and array methods
-
.unshift()
Inserts new elements at the start of an array, and returns the new length of the array.
-
.push()
Appends new elements to the end of an array, and returns the new length of the array.
-
.shift()
Removes the FIRST element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.
-
.pop()
Removes the LAST element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.
-
.map()
Calls a defined callback function on each element of an array, and returns an array that contains the results.
-
.filter()
Returns the elements of an array that meet the condition specified in a callback function.
-
.sort()
Sorts an array in place. This method MUTATES the array and returns a reference to the same array.
-
.indexOf()
Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
-
.slice()
Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.
-
.splice()
Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
-
.includes()
Determines whether an array includes a certain element, returning true or false as appropriate.
-
.forEach()
Performs the specified action for each element in an array.
-
.every()
Determines whether all the members of an array satisfy the specified test.
-
.find()
Returns the value of the first element in the array where predicate is true, and undefined otherwise.
-
.reverse()
Reverses the elements in an array in place. This method MUTATES the array and returns a reference to the same array.
-
.reduce()
Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.