Search⌘ K
AI Features

Arrays in Javascript

Explore various JavaScript array operations through practical exercises. Learn to locate, modify, and manipulate array elements, count occurrences, find duplicates, and transform values to strengthen your array handling skills.

We'll cover the following...

Assess your skills

Test your concepts of arrays by determining the location of an item in an array.

Javascript (babel-node)
indexOf = function(arr, item) {
}

Evaluate your concepts by populating an array.

Javascript (babel-node)
sum = function(arr) {
}

Evaluate yourself by returning a new array after removing all instances of a value from an array.

Javascript (babel-node)
// Returns a new array
remove = function(arr, item) {
}

Evaluate yourself by removing all instances of a value from an array (modify the original array).

Javascript (babel-node)
// Modifies the original array
removeWithoutCopy = function(arr, item) {
}

Evaluate yourself by adding an item to the end of an array.

Javascript (babel-node)
// Appends to the original array
append = function(arr, item) {
}

Evaluate yourself by removing the last item of an array.

Javascript (babel-node)
// Modifies the original array
truncate = function(arr) {
}

Test yourself by Adding an item at the beginning of an array.

Javascript (babel-node)
// Prepends to the original array
prepend = function(arr, item) {
}

Test yourself by removing the first item of an array.

Javascript (babel-node)
// Modifies the original array
curtail = function(arr) {
}

Test yourself by joining together two arrays.

Javascript (babel-node)
// Returns a new array containg both arrays
concat = function(arr1, arr2) {
}

Test yourself by adding an item anywhere in an array.

Javascript (babel-node)
// Inserts an element in the original array
insert = function(arr, item, index) {
}

Test yourself by counting the occurrences of an item in an array.

Javascript (babel-node)
count = function(arr, item) {
}

Test yourself by finding the duplicates in an array

Javascript (babel-node)
// return all elements that occur more than once
duplicates = function(arr) {
}

Test yourself by Squaring each number in an array.

Javascript (babel-node)
// return a new array with each item squared
square = function(arr) {
}

Test yourself by finding all the occurrences of an item in an array.

Javascript (babel-node)
// return a new array containing all indexes of all occurances of the target item
findAllOccurrences = function(arr, target) {
}