Advance Array Exercise 1.0

//Create an array using forEach that has all the usernames with a "!" to each of the usernames


 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"]

},


];


let newArray = [];

array.forEach(user => {

let { username } = user;

username = username + "!";

newArray.push(username);

})

console.log(newArray);




Comments