Arrays Flashcards

1
Q

What is a variable that represents a list of values? Answer with one word.

A

array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

An array comprises any number of ______. (“Values” would be correct, but I’m looking for another word.)

A

elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The number inside the square brackets is the element’s ____.

A

index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In an array, the numbering starts with __.

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Create a new array, nums, comprising three numbers from 3 to 5.

A

var nums = [3, 4, 5];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

var names = [“Alf”, “Bo”, “Gail”];

A

alert(names[2]);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Create an array with a single element, a string. The array hasn’t been declared beforehand.

A

var airlines = [“Delta”];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Create an array with three elements that are numbers. It hasn’t been declared beforehand.

A

var winningNumbers = [141, 12, 8890];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Assign to a variable the first element of an array. The variable hasn’t been declared beforehand.

A

var mealExpense = expenses[0];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Create an array with three elements: a number, a string, and a variable. The array has been declared beforehand.

A

list = [1, “one”, one];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Create an array with two string elements. Then assign the last element in the array to a variable. Neither the array nor the variable have been declared beforehand.

A
var networks = ["NBC", "CBS"];
var net2 = networks[1]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

var names = [“Alf”, “Bo”, “Gail”];

A

alert(names[2]);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly