const array = [
{
username: "john",
team: "red",
score: 5,
items: ["ball", "book", "pen"]
},
{
username: "becky",
team: "blue",
score: 10,
items: ["tape", "backpack", "pen"]
},
{
username: "susy",
team: "red",
score: 55,
items: ["ball", "eraser", "pen"]
},
{
username: "tyson",
team: "green",
score: 1,
items: ["book", "pen"]
},
];
using this array ,reate an array using forEach that has all the usernames with a "!" to each of the usernames:
let newArray = []
array.forEach(user => {
let { username } = user;
username = username + "!";
newArray.push(username);
})
console.log(newArray);
i couldnt understand this syntax. i mean why did we use {} after let ?