wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Mastering JavaScript Array Methods

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What method would you use to add one or more elements to the end of an array?

a)

Use the 'unshift' method.

b)

Use the 'shift' method.

c)

Use the 'push' method.

d)

Use the 'splice' method.

2.

Which method creates a new array with all elements that pass the test implemented by the provided function?

a)

map

b)

reduce

c)

forEach

d)

filter

3.

How do you remove the last element from an array?

a)

Use array.delete() in Python

b)

Use array.pop() in JavaScript or array.pop() in Python.

c)

Use array.shift() in both JavaScript and Python

d)

Use array.remove() in JavaScript

4.

What method would you use to find the index of a specific element in an array?

a)

Use the 'find' method in JavaScript

b)

Use the 'search' method in Python

c)

Use the 'locate' method in JavaScript

d)

Use the 'indexOf' method in JavaScript or the 'index' method in Python.

5.

Which method can be used to combine two or more arrays?

a)

arrayJoin() function

b)

concat() or '+' operator

c)

combineArrays() method

d)

merge() function

6.

What is the purpose of the `map` method in JavaScript arrays?

a)

The `map` method merges two arrays into one.

b)

The `map` method sorts the elements of an array in ascending order.

c)

The purpose of the `map` method is to transform each element of an array and return a new array with the transformed elements.

d)

The `map` method filters elements of an array based on a condition.

7.

How can you reverse the order of elements in an array?

a)

Remove all elements and add them back in the original order.

b)

Use the 'reverse()' method or iterate from the end to the beginning.

c)

Use the 'shuffle()' method to randomize the array.

d)

Use the 'sort()' method to arrange elements alphabetically.

8.

What method would you use to sort the elements of an array?

a)

Use a random number generator.

b)

Apply a filter function to remove duplicates.

c)

Use a sorting algorithm or built-in sort function.

d)

Reverse the array elements.

9.

How do you create a shallow copy of an array?

a)

Use the spread operator, slice method, or Array.from method.

b)

Use the filter method

c)

Use the push method

d)

Use the concat method

10.

Which method removes the first element from an array?

a)

shift

b)

remove

c)

pop

d)

slice

11.

What does the `filter` method return?

a)

An object containing the filtered elements.

b)

An array of all elements in the original array.

c)

A new array containing the elements that pass the test.

d)

A single element that matches the test.

12.

How can you check if an array includes a certain value?

a)

Check if the value is equal to the first element of the array.

b)

Use array.includes(value) to check if the array includes the value.

c)

Use array.find(value) to determine if the array includes the value.

d)

Use array.contains(value) to check if the array includes the value.

13.

What method would you use to join all elements of an array into a string?

a)

array.merge(separator)

b)

array.append(separator)

c)

array.join(separator)

d)

array.concat(separator)

14.

How do you find the maximum value in an array of numbers?

a)

Sort the array and take the first element.

b)

Iterate through the array and keep track of the maximum value.

c)

Select a random number from the array.

d)

Use the average of the array values.

15.

What is the purpose of the `reduce` method in JavaScript arrays?

a)

To filter out elements from an array based on a condition.

b)

To create a new array by mapping each element to a different value.

c)

The purpose of the `reduce` method is to reduce an array to a single value by executing a provided function on each element.

d)

To sort an array in ascending order.