Arrays: adding and removing elements Flashcards
var finalScores = ____
[];
counties is an empty array. What is the value of counties[0]?
undefined
What keyword removes the last element from an array?
pop
What keyword adds one or more elements to the end of an array?
push
Assign the number 1 to the 10th element of the array nums.
nums[9] = 1;
Remove the last element from the array pets.
pets.pop();
Create an empty array.
var airlines = [];
Change the value of the first element of an array to a new string.
names[0] = “Ted”;
Add a new element, a number, to the end of an array.
prices.push(99);
Assign string values to the second and fourth elements of an array.
names[1] = "Sue"; names[3] = "Kate";
add three number elements to end of an array.
prices.push(59, 79, 99);
Assign the number 1 to the 10th element of the array nums.
nums[9] = 1;