ES6 - Write Concise Object Literal Declarations Using Object Property Shorthand

Hey guys,
Me again, sorry for bothering you this much.

I resolved the problem but i was wondering on how should i use it ?
Shall i create an object ?
I am a little bit lost here …

  **Your code so far**
const createPerson = (name, age, gender) => ({name, age, gender}); 
  **Your browser information:**

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

Challenge: ES6 - Write Concise Object Literal Declarations Using Object Property Shorthand

Link to the challenge:

How should you use what?
I don’t understand what you are asking about

I mean, is there any functional example that use this particular code ?
I can’t see the scope of action for it :frowning:

You can create an object with it

const createPerson = (name, age, gender) => ({name, age, gender});

const emily = createPerson('Emily', 32, 'X');

console.log(emily) // {name: 'Emily', age: 32, gender: 'X'}
1 Like

Thank you so much !
I can now start to see javascript more clearly :slight_smile: