const players = [
{
name: "alice",
team: "yellow",
points: 15,
inventory: ["gloves", "hat", "socks"]
},
{
name: "david",
team: "purple",
points: 20,
inventory: ["scarf", "sunglasses", "socks"]
},
{
name: "lisa",
team: "yellow",
points: 30,
inventory: ["gloves", "umbrella", "socks"]
},
{
name: "peter",
team: "orange",
points: 5,
inventory: ["hat", "socks"]
},
];
By utilizing the above player array, create a new array using forEach that adds an exclamation mark to the end of each player's name:
let modifiedArray = []
players.forEach(player => {
let { name } = player;
name = name + "!";
modifiedArray.push(name);
})
console.log(modifiedArray);
I am puzzled by this code. Why did we use '{}' after 'let' in this case?