function
as follows:
```js
const person = {
name: "Taylor",
sayHello: function() {
return `Hello! My name is ${this.name}.`;
}
};
```
With ES6, You can remove the function
keyword and colon altogether when defining functions in objects. Here's an example of this syntax:
```js
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);
```