Front-end app React "Team Stats" exercise

Course: Create a Front-End App with React Skill Path
TOC: Objects

For the following question 7 in the exercise “Team Stats”:
"We want to add a new player to our team. Add a .addPlayer() method to the team object. This method should take in three parameters: newFirstName, newLastName, and newAge.

Inside the method, create a player object by setting the three parameters to be the values for the object’s three properties: firstName, lastName, age. Finally, add the player object to the team‘s _players array."

I found myself rather lost on how to achieve this… I was aware of the methods to use… but not how to put it all together… is there any reco’s on how to better brush up on the syntax… so I feel more prepared to handle questions like this…

My challenge:

when I was asked to create a method… I thought about creating a function within the object… but the video demonstrate a simple property assignment with parameters specified on the property. Or is this essentially the same as a function? I would think it should be function because it would be doing two things:

  1. creating an object
  2. appending it to the existing list of _players…
    …maybe i’m tired and just not seeing the connection…

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile: