Object property shorthand question

Tell us what’s happening:
Describe your issue in detail here.

Why does the example show parenthesis and brackets around the properties, but the interactive portion passes with just brackets?

  **Your code so far**

const createPerson = (name, age, gender) => {
// Only change code below this line
return { 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/98.0.4758.82 Safari/537.36

Challenge: Write Concise Object Literal Declarations Using Object Property Shorthand

Link to the challenge:

They are using an implicit return in the example. To return an object with the explicit return pattern, you need to use ()s:

1 Like

Ahh ok interesting. Thanks!

In the challenge examples, the function body is not defined with curly braces and if you were to place only the object, without parenthesis, the object curly braces would be read as the function body(so there will be no object at all and the content within wont be valid js

const getMousePosition = (x, y) => { x, y };  //that wont work
1 Like