Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1students.push(new Student('Ava', 7)); | Afor (const s of students) { if (s.name === 'Ava') { found = s; } } | |
| 2for (const s of students) { s.greet(); } | BCreates a new Student object and adds it to the end of the students array | |
| 3To find the total of one property across all objects in an array, add it up inside a loop | CVisits each Student object in the array and calls its greet() method | |
| 4To find an object by a property, loop through the array and check each object's property | DIt reads points from the whole array instead of the current object. It should be total += s.points; | |
| 5students.push(Student('Ava', 7)); | EThe new keyword is missing, so Student is called like a normal function and no object is created. It should be students.push(new Student('Ava', 7)); | |
| 6for (const s of students) { total += students.points; } | Flet total = 0; for (const s of students) { total += s.points; } |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
students.push(new Student('Ava', 7)); — Makes a new Student object and adds it to the end of the students array. You can then loop over the array and call each object's methods.students.push(new Student('Ava', 7));for (const s of students) {
s.greet();
}for (const s of students) {
if (s.name === 'Ava') found = s;
}let total = 0;
for (const s of students) total += s.points;const students = [];
students.push(new Student('Liam', 8));