map()
JS · Arrayssyntax
arr.map(callback(element, index, array))example
const prices = [10, 25, 50];
const withTax = prices.map(p => +(p * 1.08).toFixed(2));
console.log(withTax);output
[10.8, 27, 54]Note map() returns a new array of the same length. If you do not need the return value, use forEach() instead.