JavaScript map method creates a new array with the results of the function called on an array.
Lets say an array of 5 pizzas where you want to add Pepperoni as topping on them all.
let pizza = ['pizza', 'pizza', 'pizza', 'pizza', 'pizza']
You can simply add it by calling the map method on the array.
let added_pepperoni = pizza.map(pizza => pizza + ' with pepperoni');
And all your pizza topping are added.
[
'pizza with pepperoni',
'pizza with pepperoni',
'pizza with pepperoni',
'pizza with pepperoni',
'pizza with pepperoni'
]
Your feedback is warmly welcomed.
Thanks for reading !