Arrays Flashcards
What is a variable that represents a list of values? Answer with one word.
array
An array comprises any number of ______. (“Values” would be correct, but I’m looking for another word.)
elements
The number inside the square brackets is the element’s ____.
index
In an array, the numbering starts with __.
0
Create a new array, nums, comprising three numbers from 3 to 5.
var nums = [3, 4, 5];
var names = [“Alf”, “Bo”, “Gail”];
alert(names[2]);
Create an array with a single element, a string. The array hasn’t been declared beforehand.
var airlines = [“Delta”];
Create an array with three elements that are numbers. It hasn’t been declared beforehand.
var winningNumbers = [141, 12, 8890];
Assign to a variable the first element of an array. The variable hasn’t been declared beforehand.
var mealExpense = expenses[0];
Create an array with three elements: a number, a string, and a variable. The array has been declared beforehand.
list = [1, “one”, one];
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.
var networks = ["NBC", "CBS"]; var net2 = networks[1]
var names = [“Alf”, “Bo”, “Gail”];
alert(names[2]);