map over an array and create a new array based of object value code example
Example 1: javascript map array
const myArray = ['Sam', 'Alice', 'Nick', 'Matt'];
const newArray = myArray.map(name => {
return 'My name is ' + name;
});
console.log(newArray);
const anotherArray = myArray.map((value, index) => index + ": " + value);
console.log(anotherArray);
console.log(myArray);
Example 2: javascripr array.map
array.map( item => item.id )
array2.map( item => item.toString() )
array2.map( item => item * 3 )