diff --git a/curriculum/challenges/_meta/es6/meta.json b/curriculum/challenges/_meta/es6/meta.json index 748be5ab01..f0c318689e 100644 --- a/curriculum/challenges/_meta/es6/meta.json +++ b/curriculum/challenges/_meta/es6/meta.json @@ -78,7 +78,7 @@ ], [ "587d7b8a367417b2b2512b4f", - "Write Concise Object Literal Declarations Using Simple Fields" + "Write Concise Object Literal Declarations Using Object Property Shorthand" ], [ "587d7b8b367417b2b2512b50", diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-simple-fields.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md similarity index 65% rename from curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-simple-fields.english.md rename to curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md index b26c2d3577..621b8db2c2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-simple-fields.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md @@ -1,6 +1,6 @@ --- id: 587d7b8a367417b2b2512b4f -title: Write Concise Object Literal Declarations Using Simple Fields +title: Write Concise Object Literal Declarations Using Object Property Shorthand challengeType: 1 --- @@ -16,7 +16,7 @@ const getMousePosition = (x, y) => ({ }); ``` -getMousePosition is a simple function that returns an object containing two fields. +getMousePosition is a simple function that returns an object containing two properties. ES6 provides the syntactic sugar to eliminate the redundancy of having to write x: x. You can simply write x once, and it will be converted tox: x (or something equivalent) under the hood. Here is the same function from above rewritten to use this new syntax: @@ -28,7 +28,7 @@ const getMousePosition = (x, y) => ({ x, y }); ## Instructions
-Use simple fields with object literals to create and return a Person object with name, age and gender properties. +Use object property shorthand with object literals to create and return an object with name, age and gender properties.
## Tests @@ -36,10 +36,10 @@ Use simple fields with object literals to create and return a Person{name: "Zodiac Hasbro", age: 56, gender: "male"}.' - testString: 'assert((() => {const res={name:"Zodiac Hasbro",age:56,gender:"male"}; const person=createPerson("Zodiac Hasbro", 56, "male"); return Object.keys(person).every(k => person[k] === res[k]);})(), ''The output is {name: "Zodiac Hasbro", age: 56, gender: "male"}.'');' - - text: No key:value were used. - testString: getUserInput => assert(!getUserInput('index').match(/:/g), 'No key:value were used.'); + - text: 'createPerson("Zodiac Hasbro", 56, "male") should return {name: "Zodiac Hasbro", age: 56, gender: "male"}.' + testString: assert.deepEqual({name:"Zodiac Hasbro",age:56,gender:"male"}, createPerson("Zodiac Hasbro", 56, "male")); + - text: Your code should not use key:value. + testString: getUserInput => assert(!getUserInput('index').match(/:/g)); ```