How is the key & value decided for the properties

I would like to know how is the key & value decided for the properties of id,name and image

here you go, basically, it’s the same code, I’ve just added:

  • two friends values into key array friends
  • and used and printed makeUser function
//same code as OP
const makeUser = (id, name, image) => {
  return({
    id, //Value Shorthand
    name, //Value Shorthand
    image, //Value Shorthand
    friends: ["no new friends", "some friends"], //added this
    posts: [],
    addFriend (friend) {
       this.friends.push(friend);
    },
    createPost (post) {
      this.posts.push(post);
    }
  })
}

let newUser = makeUser(1,'Mario', true); //calling make User funciton
console.log(newUser.friends[0]) //printing array[0] of newUser 

5 Likes