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 | |
|---|---|---|
| 1bark() { console.log(this.name + " says woof"); } | AWrong - calling a method needs parentheses | |
| 2myDog.bark(); | BCalls the bark method on the myDog instance | |
| 3A function declared inside a class, without 'function' | CDeclares a method that prints the dog's name and a sound | |
| 4Refers to the instance a method is called on | DWrong - class methods don't use the 'function' keyword | |
| 5function bark() { console.log("woof"); } | Ethis | |
| 6myDog.bark; | Fshow() { ... } |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
method — A function declared inside a class body, called on an instance using dot notation.bark() {
console.log(this.name + " says woof");
}myDog.bark();show() {
console.log(this.color);
}myCar.show();console.log(this.name + " says woof");