wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Javascript Arrays

Total questions: 18

Worksheet time: 17mins

Name
Class
Date
1.
An array is;
a)
Shapes
b)
Sizes
c)
Options
d)
Lists of data
2.

What is first index value of an array?

a)

-1

b)

0

c)

1

d)

undefine

3.
What surrounds an array?
a)
Quotations
b)
Curly Brackets
c)
Parenthesis
d)
Square Brackets
4.
array = [1,2,3,4,5]
What is the length of this array?
a)
5
b)
4
c)
0
d)
125.4
5.

Which definition below best describe an array?

a)

An array is a function identifier that can hold more than one parameter.

b)

An array is a beam of light.

c)

An array is a special variable, which can hold more than one value at a time.

d)

An array is a special function, which can hold more than one value at a time.

6.

What is proper syntax for declaring a array in JavaScript?

a)

var arrayName =[ ];

b)

var arrayName[ ] ={ };

c)

array arrayName ={ };

d)

obj var arrayName =[ ];

7.

Which of the variables below is an array?

a)

var names="array"

b)

var names = array;

c)

var names = [];

d)

var names[];

8.

What will be the output to the console for the following code:


var colors =["Red", "Green", "Yellow", "Orange", "Blue"];

colors.splice(0,3, "Purple");

console.log(colors);

a)

["Purple", "Green", "Yellow"]

b)

["Purple", "Green", "Yellow", "Orange", "Blue"]

c)

["Red", "Green", "Yellow", "Orange", "Blue"]

d)

["Purple", "Orange", "Blue"]

9.
How would you change the first element in an array?
a)
nums[1] = "New!";
b)
nums = "New!";
c)
var nums[1] = "New!";
d)
nums[0] = "New!";
10.
array = [1,2,3,4,5];
What is the highest position in this array?
HINT: Remember arrays start at position 0!
a)
4
b)
5
c)
0
d)
125.7
11.
What property tells you how many items are in an array?
a)
length
b)
count
c)
items
d)
num
12.
Which is the correct code to remove the 1 from this array?:
arr = [1,2,3,4,5];
a)
arr.append(6);
b)
arr.splice(0, 1);
c)
splice(arr, 6);
d)
append(arr, 6);
13.
array = [1,2,3,4,5]
What would the array look like after we execute this?:
array.splice(0, 1);
a)
[2,3,4,5]
b)
[2,3,4,5,1]
c)
[1,2,3,4]
d)
[5,4,3,2]
14.

The length() method for an array will return _____.

a)

the number of elements in the array

b)

the last index value of the array.

c)

the length of the name of the array variable

d)

the capacity of the array

15.

The push() method adds a new element to the end of an array

a)

true

b)

false

16.
How would you access the second element in an array?
a)
nums.2
b)
nums[2]
c)
nums_1
d)
nums[1]
17.
Which of these lines of code show how to validly store an array with 3 items?
a)
var nums = [42, 3, 7];
b)
var nums = 3, 42, 7;
c)
var nums = [3];
d)
var nums = (3, 42, 7);
18.
Which of these for loops would iterate through each item of the nums array (no more, no less)?
a)
for (var i = 0; i < nums; i++) { }
b)
for (var i = 1; i < nums.length; i++) { }
c)
for (var i = 1; i < nums; i++) { }
d)
for (var i = 0; i < nums.length; i++) { }