function
as follows:
const person = {With ES6, You can remove the
name: "Taylor",
sayHello: function() {
return `Hello! My name is ${this.name}.`;
}
};
function
keyword and colon altogether when defining functions in objects. Here's an example of this syntax:
const person = {
name: "Taylor",
sayHello() {
return `Hello! My name is ${this.name}.`;
}
};
setGear
inside the object bicycle
to use the shorthand syntax described above.
setGear
should be a declarative function.
testString: assert(typeof bicycle.setGear === 'function' && code.match(/setGear\s*\(.+\)\s*\{/));
- text: bicycle.setGear(48)
should change the gear
value to 48.
testString: assert((new bicycle.setGear(48)).gear === 48);
```