ES6 Course, Object Property Shorthand Topic Issue

I encountered an issue with the default code to work on in this specific course topic, which might cause unnecessary confusion to other beginners like me. Here’s the default code:

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 problem I have with this is that the comments say to only change the code within the designated area, but you’ll need to add parentheses outside the curly brackets that define the whole function, which is outside the supposed area of code that is to be only strictly edited.

Here’s the working solution:

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

This is my first post and I don’t know how to make the codes above look like they’re actual codes like I see in the other posts, so please forgive me. I hope this makes sense.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

That is one possible solution, but another solution exists that doesn’t require changes outside of the commented area.

1 Like

you have deleted the return statement and made it implicit return, try keeping the return keyword…

2 Likes

Thank you for the info :pray:

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