Given an array, I am trying to use map to add an exclamation mark to each item in the array.
For example:
Before - items: ["ball", "book", "pen"]
After - items: ["ball!","book!","pen!"]
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"]
},
];
This is what I have tried in my JavaScript:
const PlusItems = array.map(user => user.items+'!');
console.log(PlusItems);