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 | |
|---|---|---|
| 1constructor(name, score) { | AThe constructor was changed to need two values, but this new call was not updated, so score is undefined. | |
| 2this.score = score; | BaddPoints(n) { this.score += n; } | |
| 3After adding a score parameter to the constructor, update the code that creates objects so it passes the new value. | CThe constructor now takes a new parameter, score, so every new call must be updated to pass it in. | |
| 4Adding a new method to a class means writing it inside the class body, then calling it on an object. | DAdds a new property to the class by saving the score parameter on each object that is created. | |
| 5constructor(name, score) { this.name = name; } let p = new Player('Ava', 10); | EThe score parameter was added but never stored with this.score = score, so the object has no score property. | |
| 6constructor(name, score) { ... } let p = new Player('Ava'); | Flet p1 = new Player('Ava', 10); |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
this.score = score; — Modifying a class: add or change a constructor parameter, property or method, then update every new call that creates its objects and re-run your tests.constructor(name, score) {
this.name = name;
this.score = score;constructor(name, score) {
this.name = name;
this.score = score;addPoints(n) {
this.score += n;
}const p1 = new Player("Ava", 10);const p = new Player("Ava", 10);
p.addPoints(5);
console.assert(p.score === 15);