
array.map() – Creates a **new array** by executing the callback on every element.
๐ Syntax
newArray = array.map((element, index, array) => {
return /* transformed value */;
}, thisArg);
๐งช Example
const prices = [10, 20, 30];
const withGST = prices.map(p => p * 1.18);
console.log(withGST); // [11.8, 23.6, 35.4]
Comments
Post a Comment