- What is map()?
map() is a method of the Array object.
- It allows you to create a new array by applying a function to each element of the original array
- returns a new array
const nums = [1, 2, 3, 4];
const multipyThree = nums.map((current, index, originalArray) => {
return current * 3;
});
console.log(multipyThree) // [3, 6, 9, 12]
const multipyThreeAndIndex = nums.map((current, index, originalArray) => {
return num * 3 + index;
});
console.log(multipyThreeAndIndex); // [3, 7, 11, 15]
Map Polyfill Javascript