Asked by amaya battle
Question: 1
Given the array:
var numbers = [0, 1, 2, 3, 4];
How can we correctly add the number 5 to the end of the array?
numbers[5] = 5;
numbers.push(5);
numbers[0] = 5;
numbers.pop(5);
Question: 2
You are building a program for a small grocery store. The program needs to store the following items customers want to buy:
Milk
Bread
Eggs
Apples
You want to keep all the items together in one variable so you can later display them, add more items, or remove items.
Which of the following is the BEST way to store these items in JavaScript?
var groceries = “Milk, Bread, Eggs, Apples”;
var groceries = [“Milk Bread Eggs Apples”];
var groceries = [“Milk”, “Bread”, “Eggs”, “Apples”];
var groceries = Milk, Bread, Eggs, Apples;
Question: 3
A teacher is building a program to store student names:
var students = [“Jordan”, “Ava”, “Malik”];
She wants to add “Sofia” to the end of the list.
Which line of code should she use?
students.add(“Sofia”);
students.push(“Sofia”);
students[0] = “Sofia”;
students.pop(“Sofia”);
Question: 4
Given the array:
var numbers = [0, 1, 2, 3, 4, 5];
How can we remove the last item from the array and store it in a variable called value?
var value = numbers[5];
var value = numbers.pop();
var value = numbers.push();
var value = numbers;
Question: 5
What kinds of items can we store in arrays in JavaScript?
Numbers only
Strings of text only
Numbers or strings of text
Any kind of object (anything you can store in a variable)
Question: 6
You are building a shopping app. The program stores items in an array:
You want to replace “cake” with “apples”.
var shoppingList = [“milk”, “eggs”, “bread”, “juice”, “cake”, “chips”];
shoppingList[“cake”] = “apples”;
shoppingList[“apples”] = “cake”;
shoppingList[4] = “apples”;
shoppingList[5] = “apples”;
Question: 7
What index refers to the “end” of an array?
The lowest index, index 0
The highest index
The middle index
The negative index
Question: 8
Jordan is creating a program that stores student test scores in an array:
Which line of code will correctly find the number of items in the array?
scores.len
scores.length
length(scores)
scores.length()
Question: 9
A game stores player scores in an array:
var scores = [100, 85, 92, 70];
Which line of code correctly returns the number of elements in the scores array?
scores.size
scores.length()
scores.length
length(scores)
Question: 10
In JavaScript, which number represents the position of the first item in an array?
0
1
-1
2
Question: 11
Maria is building a program to store her test scores:
85, 90, 78, and 92.
She wants to keep all the scores together in one variable so she can calculate the average later.
Which of the following should Maria use?
A loop
A function
An array (list)
A conditional statement
Question: 12
Which loop will correctly go through the array arr and print each value?
for(var i = 0; i < arr.length(); i++){
var curr = arr[i];
println(curr);
}
for(var i = 1; i <= arr.length(); i++){
var curr = arr[i];
println(curr);
}
for(var i = 0; i < arr.length; i++){
var curr = arr[i];
println(curr);
}
for(var i = 1; i <= arr.length; i++){
var curr = arr[i];
println(curr);
}
Question: 13
What is an array (or list)?
An unordered collection of unique items
An ordered collection of items
A collection of (key, value) pairs
A collection of items stored at (row, column) locations
Question: 14
You are creating a grocery app that stores items in an array:
A customer removes the last item from the cart.
Which command will remove the last item?
cart.remove();
cart.pop();
cart.push();
cart.delete();
Question: 15
Which of the following will create an empty list and assign it to arrList?
var arrList = [ ]
var arrList = 0
var arrList = [0]
var arrList = ” “
All Answers 1
Answered by
GPT-5 mini
AI
1) numbers.push(5);
2) var groceries = ["Milk", "Bread", "Eggs", "Apples"];
3) students.push("Sofia");
4) var value = numbers.pop();
5) Any kind of object (anything you can store in a variable)
6) shoppingList[4] = "apples";
7) The highest index
8) scores.length
9) scores.length
10) 0
11) An array (list)
12) for(var i = 0; i < arr.length; i++){ var curr = arr[i]; println(curr); }
13) An ordered collection of items
14) cart.pop();
15) var arrList = []
2) var groceries = ["Milk", "Bread", "Eggs", "Apples"];
3) students.push("Sofia");
4) var value = numbers.pop();
5) Any kind of object (anything you can store in a variable)
6) shoppingList[4] = "apples";
7) The highest index
8) scores.length
9) scores.length
10) 0
11) An array (list)
12) for(var i = 0; i < arr.length; i++){ var curr = arr[i]; println(curr); }
13) An ordered collection of items
14) cart.pop();
15) var arrList = []
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.