Example Syntax Incorrect in Lesson

Tell us what’s happening:
To follow the syntax of the lesson, it is necessary to modify code outside of the boundaries specified in the sample code as you need to insert parentheses before and after the curly braces of the function.

  **Your code so far**

const createPerson = (name, age, gender) => ({
// Only change code below this line
name, age, gender
// Only change code above this line
});
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36

Challenge: Write Concise Object Literal Declarations Using Object Property Shorthand

Link to the challenge:

Hi,

I will try to give you some hints for the challenge…

The starting code is:

const createPerson = (name, age, gender) => {
  // Only change code below this line
  return {
    name: name,
    age: age,
    gender: gender
  };
  // Only change code above this line
};

the instructions: Use object property shorthand with object literals to create and return an object with name , age and gender properties.

So the function should still return something… that something should be an object and the object should have properties name, age, gender

What that challenge want to teach you is that you can use the shorthand to create an object and assign it a variables…

so for example if you have this code:

const name = "Alex";
const age = 30;

and you want to create an object with name and age properties, you can do it
either

const result = {
  name: name,
  age: age
}

or take advantage of the fact that the key and the variable name you want to assign to the key have same name and use a shorthand:

const result {
  name,
  age
}

the result will be same, just the syntax is different.

So now you just need to adjust the return value from that function you have in your challenge and use that shorthand syntax.

Hopefully now it is clear. If not, let me know and I will try to explain it more.

You can also find explanations here:

As said, you do not need to change it to an implicit return.

But I will say that showing the example code with an implicit return and then asking for an explicit return is probably not the best idea.