Total noob here, so I might have googled with the wrong keywords. I am sorry if this has been answered a million times before.
I have a constructor function:
function CreateTeam(teamId, name, matchesPlayed, won, drawn, ...)
Giving an object some keys like: teamId
, teamName
, matchesPlayed
, matchesWon
and so on.
When calling the the constructor function I do it like this:
const argentina = new CreateTeam ('a1', 'Argentina', 0, 0, 0, ...)
I am wondering if it is possible to take the name of a constant and copy/paste it as a value of an object? In this case I would like to paste it as the second value (the value of argentina.name
)
If this is possible I would be able to avoid typing the team name for every time I call the CreateTeam
constructor function.
Any suggestions? Again, sorry if this has been answered before, and I just don't know the syntax well enough to search for it.