I’m wondering if anyone can help explain if my method of pushing a new player object to the array is OK or if it would be considered bad practice for some reason. I always like to watch the walkthrough after I complete the projects to get insight at others’ problem solving approach. As far as I can tell, both output the end result correctly.
The way I decided to do it was:
addPlayer(newFirstName,newLastName,newAge){
this.players.push({firstName:newFirstName,lastName:newLastName,age:newAge})
},
The video walkthough, however, completed it like this.
addPlayer(newFirstName, newLastName, newAge){
let player = {
firstName: newFirstName,
lastName: newLastName,
age: newAge
};
this.players.push(player);
}