Unit 5
Lesson 2 Lists Investigate
Unit 5 Lesson 3 - Warm Up
List -
Element -
Index -
an ordered collection of elements
an individual value in a list that is assigned a unique index
a common method for referencing the elements in a list or string using numbers
Array -
a data structure in JavaScript used to represent a list.
Warm-up
1. What is the output of the following code segment?
var strListOne = ["x", "y", "z", "3"];
console.log(strListOne[1] + strListOne[2]);
2. What is the output of the following code segment?
var strListTwo = ["x", "y", "5", "z"];
insertItem(strListTwo, 2, "d");
console.log(strListTwo[2] + strListTwo[3]);
Warm-up
3. What is the output of the following code segment?
var strListThree = ["x", "y", "z"];
appendItem(strListThree, "t");
removeItem(strListThree, 2);
console.log(strListThree.length + " " + strListThree[2]);
4. What is the output of the following code segment?
var myArray = [1,2,4,7,8,10];
var n = myArray[myArray.length-1];
console.log(n);
Using list.length-1 to access last item in array
var myArray = [1,2,4,7,8,10];�var last = myArray[myArray.length-1];�console.log(last);
>> 10
Go over homework
goFormative U5L02 Lists Investigate
Log into Code.org Unit 5 Lesson 2 bubble 2
AP Classroom 2021 Test REVIEW 3-2 Unit 4 programming
Homework