Map

👨‍💼 Perfect! You've used map to transform arrays in different ways.
🦉 Notice how TypeScript inferred the types:
  • names is Array<string>
  • prices is Array<string>
  • summary is Array<{ name: string; priceLabel: string }>
The parentheses around the object literal in map are important:
// ✅ Correct - returns an object
products.map((p) => ({ name: p.name }))

// ❌ Wrong - curly braces interpreted as function body
products.map((p) => {
	name: p.name
}) // Returns undefined!

Please set the playground first

Loading "Map"
Loading "Map"
Login to get access to the exclusive discord channel.