JavaScript Algorithms and Data Structures testing properties 2

Tell us what’s happening:
Describe your issue in detail here.
I changed the code despite the messages for only change between the lines so that my answer fix more with the examples. It worked, but it was different from the posted solution. It is shorter if that helps.

  **Your code so far**

const createPerson = (name, age, gender) => ({
  name,
  age,
  gender
});
// 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/94.0.4606.81 Safari/537.36

Challenge: Write Concise Object Literal Declarations Using Object Property Shorthand

Link to the challenge:

Yeah, you have pretty much the standard solution for this, except that you’ve used the arrow function’s implicit return instead of the explicit return that the example uses. The implicit return was discussed here. You figured out the parentheses trick for implicit returns with object literals - good.

I mean, you technically broke the “rules” - you edited outside the commented boundaries. You could have done the same thing with the explicit return. Does it matter? Maybe not. Although I would suggest that being able to follow instructions and pay close attention to detail is a good thing for a developer.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.