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 | |
|---|---|---|
| 1if (this.isPassing()) { | AThe brackets are missing, so the method is not called. this.isPassing is just the function itself, which is always truthy. It should be this.isPassing(). | |
| 2return this.getTotal() / 3; | BGets the total from another method of the same object, then divides it by 3 to give an average | |
| 3A small single-job method checks one thing, so other methods can call it with this. | CThe call is missing this. so JavaScript looks for a normal function called isPassing and throws a ReferenceError. It should be this.isPassing(). | |
| 4One method can call another method of the same class by writing this. before the method name. | DisPassing() { return this.mark >= 50; } | |
| 5report() { return isPassing(); } | Ereport() { return this.getGrade(); } | |
| 6if (this.isPassing) { return 'Pass'; } | FCalls the isPassing method on the same object and uses its true or false result in the if condition |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
this.methodName() — Inside a class, a method calls another method of the same object by writing this. before its name, such as this.isPassing(). Forgetting this. causes a ReferenceError.isPassing() { return this.mark >= 50; }
report() { return this.isPassing(); }isPassing() { return this.mark >= 50; }
status() { return this.isPassing(); }total() { return this.a + this.b; }
average() { return this.total() / 2; }addBonus(n) { this.points += n; }
win() { this.addBonus(10); }status() {
return this.isPassing() ? "Yes" : "No";
}