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
index.ts
and use the provided products fixture:
  1. Create names with map β€” product names in order: ['Laptop', 'Toaster', 'Headphones', 'Blender']
  2. Create prices with map β€” 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']
  3. Create summary with map β€” objects shaped { name, priceLabel } where priceLabel is '$' plus the price (two decimal places visible), e.g. { name: 'Laptop', priceLabel: '$999.99' }
  4. Export names, prices, and summary
πŸ’° map returns a new array of whatever your callback returns.

Please set the playground first

Loading "Map"
Loading "Map"