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!