2.1 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			2.1 KiB
		
	
	
	
	
	
	
	
id, title, challengeType, videoUrl, localeTitle
| id | title | challengeType | videoUrl | localeTitle | 
|---|---|---|---|---|
| 587d7b8b367417b2b2512b50 | Write Concise Declarative Functions with ES6 | 1 | Escribir funciones declarativas concisas con ES6 | 
Description
function palabra clave de la siguiente manera: const persona = {Con ES6, puede eliminar la palabra clave de
nombre: "taylor",
sayHello: function () {
vuelve `hola! Mi nombre es $ {this.name} .`;
}
};
function y los dos puntos por completo al definir funciones en objetos. Aquí hay un ejemplo de esta sintaxis: const persona = {
nombre: "taylor",
di hola() {
vuelve `hola! Mi nombre es $ {this.name} .`;
}
};
Instructions
setGear dentro de la bicycle objeto para usar la sintaxis abreviada descrita anteriormente. Tests
tests:
  - text: No se usó la expresión de función tradicional.
    testString: 'assert(!getUserInput("index").match(/function/),"Traditional <code>function</code> expression was not used.");'
  - text: <code>setGear</code> es una función declarativa.
    testString: 'assert(typeof bicycle.setGear === "function" && getUserInput("index").match(/setGear\s*\(.+\)\s*\{/), "<code>setGear</code> is a declarative function.");'
  - text: <code>bicycle.setGear(48)</code> cambia el valor del <code>gear</code> a 48.
    testString: 'assert((new bicycle.setGear(48)).gear === 48, "<code>bicycle.setGear(48)</code> changes the <code>gear</code> value to 48.");'
Challenge Seed
// 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
// solution required