What number represents the first index in a list in Javascript?
0
What is the purpose of a loop?
Loops are used in programming to repeat code efficiently.
An ordered collection of elements
List
What is the smallest prime number?
2
A common method for referencing the elements in a list or string using numbers
Index
What are the two types of loops we have learned?
Describe the differences of how they are written
For and while loops
For loop is more condensed on one line, while the while loop is separated into multiple lines.
An individual value in a list that is assigned a unique index
Element
What is the newest NFL team?
Houston Texans
appendItem() and insertItem()
var list = [ 2, 3, 4, 5 ];
list[3]
Occurs when the ending condition will never evaluate to true.
Infinite loop
What is the chemical symbol for gold?
Au
What is the final value of sum after this code runs?
12
What are the 3 parts of a for loop?
1. counter variable , usually called i
2. condition for loop to break
3. increment such as i++
A repetitive portion of an algorithm which repeats a specified number of times or until a given condition is met.
Iteration
Which mountain range is home to the Earth's five highest volcanoes?
The Andes
var data = ["A", "B", "C", "D"];
Which index accesses the last element, regardless of list size?
data.length - 1
What is the result of this loop?
var count = 1;
while (count >= 1) {
console.log(count);
count = count + 1;
}
Infinite loop
In your own words, describe what a traversal is and how you would create one in JavaScript.
Traversal refers to the process of visiting and accessing each element in a data structure, such as a list in a specific order. Utilizing .length in a for loop can help accomplish this task.
'avoir faim' what does this mean in English?
to have hunger
Describe two ways you access the last element in this list:
var animalsList = ["tiger", "lion", "frog"];
1st way: [animalsList.length-1]
2nd way: animalsList[2]
What is the final value of result after this code runs?
6
A list contains 100 numbers. A loop checks every number and updates a variable only when a value meets a condition.
Which two key computer science concepts are being used together?
What are iteration and selection?
What is the longest river in Asia?
Yangtze River
A program is designed to determine the minimum value in a list of positive numbers called List. The following program was written
var minimum = <MISSING CODE>
for(var i = 0; i < List.length; i++){
if (List[i] < minimum){
minimum = List[i];
}
}
console.log(“The minimum is” + minimum);
What should be put to replace <MISSING CODE> so that the program works as intended for every possible list of positive numbers?
List[0]
var arr = [2,4,6,8];
var sum = 0;
for (var i = 0; i < arr.length; i++) {
sum += arr[i] * i+1;
}
What does this print?
console.log(sum);
60
var arr = [3, 6, 9, 12];
for (var i = 0; i < arr.length; i++) {
arr[i] = arr[i] / 3;
}
console.log(arr);
What is printed?
[1, 2, 3, 4]
What is anemology?
The study of wind