0 of 7 problems solved0%
6 of 7

Price Map (Record)

Record<K, T> builds a dictionary type where each key K maps to a value T. Use it to create fast lookups from arrays. When keys repeat, decide which value wins; here the later item should overwrite the earlier one.

// Example: Record<string, number> for a price table

Your Task

Build a price table from a list of items.

  • Define type Item = { sku: string; price: number }.
  • Implement function priceMap(items: Item[]): Record<string, number>.
  • For each item, set out[item.sku] = item.price and let later items overwrite earlier ones.
  • Return an empty object for an empty input.