From 254897c372bd81919c01a057951456d33c85a3c6 Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 26 Nov 2018 16:05:01 +0530 Subject: [PATCH] fix: fixed the test and added solution --- ...eclarations-using-simple-fields.english.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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-simple-fields.english.md index 726a86a6ee..3ac0037726 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-simple-fields.english.md @@ -17,7 +17,7 @@ Here is the same function from above rewritten to use this new syntax: ## Instructions
-Use simple fields with object literals to create and return a Person object. +Use simple fields with object literals to create and return a Person object with name, age and gender properties.
## Tests @@ -25,10 +25,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 : were used. - testString: getUserInput => assert(!getUserInput('index').match(/:/g), 'No : were used.'); + - text: 'The output is {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.'); ``` @@ -63,6 +63,13 @@ console.log(createPerson("Zodiac Hasbro", 56, "male")); // returns a proper obje
```js -// solution required +const createPerson = (name, age, gender) => { + "use strict"; + return { + name, + age, + gender + }; +}; ```