NEW
Font size
S
M
L
XL
WorksheetsArrays
Total questions: 10
Worksheet time: 5mins
Name
Class
Date
1.
Which of the following are good examples of things to store as arrays or lists?
I – A to-do list
II – A grocery list
III – A ball in a game of breakout
IV – A list of balls in a game of breakout
V – A loop counter variable
I – A to-do list
II – A grocery list
III – A ball in a game of breakout
IV – A list of balls in a game of breakout
V – A loop counter variable
a)
II only
b)
III and V
c)
I, II, and IV
d)
I, II, III, IV, and V
2.
var groceries = ["milk", "sugar", "eggs", "cake"];What is the value of groceries[2] in the above array?a)
"milk"
b)
"sugar"
c)
"eggs"
d)
"cake"
3.
var shoppingList = ["milk", "eggs", "sugar", "bread", "cake"];What is the index of the item "bread" in the array shoppingList?a)
4
b)
3
c)
5
d)
6
4.
What is printed by the following lines of code?
a)
eggs
b)
bread
c)
2
d)
sugar
5.
It is possible to have an array with 0 items.
a)
true
b)
false
6.
What is the output from the following program?
a)
undefined
25
25
b)
20
25
25
c)
25
undefined
undefined
d)
20
20
20
7.
var arr = [1, 4, 55, 23, 11, 2];What is the value of arr.length?a)
5
b)
6
c)
9
d)
2
8.
var firstElement = ...Which statement will store the first element of an array arr inside of the variable firstElement?a)
var firstElement = arr[0];b)
var firstElement = arr[1];c)
var firstElement = arr[arr.length];d)
var firstElement = arr[arr.length - 1];9.
var lastElement = ...Which statement will store the last element of an array arr inside of the variable lastElement?a)
var lastElement = arr[0];b)
var lastElement = arr[1];c)
var lastElement = arr[arr.length];d)
var lastElement = arr[arr.length - 1];10.
Describe the output of the following function:
a)
starting at the beginning of the array, prints each item in the array
b)
starting at the beginning of the array, prints each index of the array
c)
starting at the end of the array, prints each item in the array
d)
starting at the end of the array, prints each index of the array
Reset
