--- id: 587d7b8b367417b2b2512b50 title: Write Concise Declarative Functions with ES6 challengeType: 1 --- ## Description
When defining functions within objects in ES5, we have to use the keyword function as follows:
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:
const person = {
  name: "Taylor",
  sayHello() {
    return `Hello! My name is ${this.name}.`;
  }
};
## Instructions
Refactor the function setGear inside the object bicycle to use the shorthand syntax described above.
## Tests
```yml tests: - text: Traditional function expression was not used. testString: assert(!getUserInput('index').match(/function/),'Traditional function expression was not used.'); - text: setGear is a declarative function. testString: assert(typeof bicycle.setGear === 'function' && getUserInput('index').match(/setGear\s*\(.+\)\s*\{/), 'setGear is a declarative function.'); - text: bicycle.setGear(48) changes the gear value to 48. testString: assert((new bicycle.setGear(48)).gear === 48, 'bicycle.setGear(48) changes the gear value to 48.'); ```
## Challenge Seed
```js // change code below this line const bicycle = { gear: 2, setGear: function(newGear) { "use strict"; this.gear = newGear; } }; // change code above this line bicycle.setGear(3); console.log(bicycle.gear); ```
## Solution
```js // solution required ```