Arrays
3 years ago
stacydolderer
Save
Edit
Host a game
Live GameLive
Homework
Solo Practice
Practice
• Question 1
30 seconds
Q. 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
II only
III and V
I, II, and IV
I, II, III, IV, and V
• Question 2
30 seconds
Q.
``var groceries = ["milk", "sugar", "eggs", "cake"];``
What is the value of `groceries[2]` in the above array?
"milk"
"sugar"
"eggs"
"cake"
• Question 3
30 seconds
Q.
``v`ar shoppingList = ["milk", "eggs", "sugar", "bread", "cake"];`
What is the index of the item `"bread"` in the array `shoppingList`?
4
3
5
6
• Question 4
30 seconds
Q. What is printed by the following lines of code?
eggs
2
sugar
• Question 5
30 seconds
Q. It is possible to have an array with 0 items.
true
false
• Question 6
30 seconds
Q. What is the output from the following program?
undefined
25
20
25
25
undefined
20
20
• Question 7
30 seconds
Q.
``var arr = [1, 4, 55, 23, 11, 2];``
What is the value of `arr.length`?
5
6
9
2
• Question 8
30 seconds
Q.
``var firstElement = ...``
Which statement will store the first element of an array `arr` inside of the variable `firstElement`?
``var firstElement = arr[0];``
``var firstElement = arr[1];``
``var firstElement = arr[arr.length];``
``var firstElement = arr[arr.length - 1];``
• Question 9
30 seconds
Q.
``var lastElement = ...``
Which statement will store the last element of an array `arr` inside of the variable `lastElement`?
``var lastElement = arr[0];``
``var lastElement = arr[1];``
``var lastElement = arr[arr.length];``
``var lastElement = arr[arr.length - 1];``
• Question 10
30 seconds
Q. Describe the output of the following function: