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 | |
|---|---|---|
| 1this.name = name; | AThe assignment is backwards. It copies the empty this.name into the parameter instead of storing the parameter on the object. It should be this.name = name; | |
| 2return this.name + ' barks'; | BInside a constructor, stores the name value on the new object as its own name property | |
| 3Inside a class, this means the object being worked on, so each object keeps its own data | CLeaving out this means JavaScript looks for a plain variable called name and throws a ReferenceError. It should be return this.name; | |
| 4A method uses this to read one of its own object's properties | Dthis.score = score; | |
| 5constructor(name) { name = this.name; } | EInside a method, reads the name property of the object the method was called on | |
| 6describe() { return name; } | Fgreet() { console.log(this.name); } |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
this.name — Inside a class, this means the object being worked on, so this.name is that object's own name property. Leaving out this causes a ReferenceError.constructor(name) {
this.name = name;
}speak() {
console.log(`I am ${this.name}`);
}constructor(pet) {
this.name = pet;
}constructor(name) {
this.name = name;
}addPoints() {
this.points += 5;
}