wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Skill #2 Array

Total questions: 12

Worksheet time: 9mins

Name
Class
Date
1.

1. Which statement correctly declares an array in JavaScript?

a)

var array = [1, 2, 3];

b)

var array = {1, 2, 3};

c)

var array = (1, 2, 3);

d)

var array = <1, 2, 3>;

2.

How do you access the third element in an array named numbers?

a)

numbers[2];

b)

numbers[3];

c)

numbers(3);

d)

numbers{2};

3.

Which of the following initializes an empty array?

a)

var array = [];

b)

var array = {};

c)

var array = ();

d)

var array = <>;

4.

How can you iterate over an array named items using a for loop?

a)

b)

c)

d)

5.

Which method adds one or more elements to the end of an array?

a)

array.push(element);

b)

array.pop();

c)

array.shift();

d)

array.unshift(element);

6.

What will be the output of the following code?

a)

"apple"

b)

"banana"

c)

"mango"

d)

undefined

7.

What does the following code return?

a)

0

b)

1

c)

2

d)

-1

8.

What will be the output of the following code?

a)

true

b)

false

c)

"apple"

d)

undefined

9.

What will be the output of the following code?

a)

[2, 4, 6]

b)

2

4

6

c)

1

2

3

d)

undefined

10.

Which of the following code snippets correctly logs each number in the array numbers?

a)

b)

c)

d)

11.

Which of the following code snippets correctly sorts the letters in ascending order?

a)

b)

c)

d)

12.

Which of the following code snippets correctly sorts the numbers in descending order?

a)

b)

c)

d)