[Need Help]Write Concise Object Literal Declarations Using Simple Fields

[Need Help]Write Concise Object Literal Declarations Using Simple Fields
0.0 0

#1

Tell us what’s happening:
I wrote the code in 3 ways (little modifications) and passed the test in every ways. It is creating confusion for me. which is the right way to solution? @PortableStick

Your code so far


**1**

const createPerson = (name, age, gender) => {
  "use strict";
  // change code below this line
  name, age, gender
  // change code above this line
};
console.log(createPerson("Zodiac Hasbro", 56, "male")); // returns a proper object

**2**

const createPerson = (name, age, gender) => {
  "use strict";
  // change code below this line
   {name, age, gender};
  // change code above this line
};
console.log(createPerson("Zodiac Hasbro", 56, "male")); // returns a proper object

**3**

const createPerson = (name, age, gender) => {
  "use strict";
  // change code below this line
  ({name, age, gender});
  // change code above this line
};
console.log(createPerson("Zodiac Hasbro", 56, "male")); // returns a proper object

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-simple-fields


#2

All of them are correct. In some cases, brackets/parenthesis are not mandatory.

It’s like this:

if (a > b) 
{return a};

is the same as:

if (a > b) 
return a;

#3

These all do pass the test, but none of them are correct. Looks like you’ve found a bug in the curriculum! If you add a return statement, you’ll find that the second two examples will return an object, but the first one will not.

edit: Filed an issue #17784