Map
👨💼 Perfect! You've used
map to transform arrays in different ways.🦉 Notice how TypeScript inferred the types:
namesisArray<string>pricesisArray<string>summaryisArray<{ 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!