Arrays Practice Quiz¶
Question 1¶
Rearrange the given code to create an array that has elements [10, 3, 42] at the end of this code.
Question 2¶
array-quiz2: What will the following program print?:
let people = ["Ali", "Samin", "Blake", "Athiela", "Monica"];
let otherPeople = people;
otherPeople[0] = "Vrajesh";
otherPeople[2] = "Hannah";
console.log(people[2])
Question 3¶
array-quiz3: What will the following program print?:
let people = ["Ali", "Samin", "Blake", "Athiela", "Monica"];
let otherPeople = structuredClone(people);
otherPeople[0] = "Vrajesh";
otherPeople[2] = "Hannah";
console.log(people[2])
Question 4¶
[8, 10, 12]
-
Yes! Nicely done!
[12, 10, 8]
-
Try again!
[4, 5, 6]
-
Try again!
[6, 5, 4]
-
Try again!
[4, 4, 5, 5, 6, 6]
-
Try again!
[6, 6, 5, 5, 4, 4]
-
Try again!
array-quiz4: What will the following program print?:
let nums = [4,5,6];
let newNums = [];
for (let i=0; i<nums.length; i++) {
let thisNumber = nums[i] * 2;
newNums.push(thisNumber);
}
console.log(newNums);
Question 5¶
[0, 0, 0, 0, 0, 6]
-
Yes! Nicely done!
[0, 0, 6]
-
Try again!
[0, 0, 0]
-
Try again!
[0, 0, 0, 0, 0, 4]
-
Try again!
[0, 0, 0, 0, 0, 0]
-
Try again!
array-quiz5: What will the following program print?:
let nums = [4,5,6];
let newNums = [];
for (let i=0; i<nums.length*2; i++) {
newNums.push(0);
}
newNums[newNums.length-1] = nums[nums.length-1];
console.log(newNums);
Question 6¶
Solve the fix23 CodingJS array problem. You do not need a loop for this problem.
Question 7¶
Solve the has12 CodingJS array problem. You will need to use a loop to solve this problem.