Map
Map
π¨βπΌ The
map method creates a new array by transforming each element.const numbers = [1, 2, 3]
const doubled = numbers.map((n) => n * 2)
// [2, 4, 6]
The callback receives each element and returns the transformed value.
π¨ Open
and use the provided
products fixture:- Create
nameswithmapβ product names in order:['Laptop', 'Toaster', 'Headphones', 'Blender'] - Create
priceswithmapβ each price formatted as a dollar string with exactly two decimal places (toFixed(2)), e.g.'$999.99':['$999.99', '$79.99', '$149.99', '$49.99'] - Create
summarywithmapβ objects shaped{ name, priceLabel }wherepriceLabelis'$'plus the price (two decimal places visible), e.g.{ name: 'Laptop', priceLabel: '$999.99' } - Export
names,prices, andsummary
π°
map returns a new array of whatever your callback returns.

