0 of 6 problems solved0%
3 of 6

Pluck User Names

Arrays of objects are everywhere. Given an array of users with shape { id: number; name: string }, create a new array containing only the name of each user.

You’ll practice typing arrays of objects and using map to transform the data without mutation.

Your Task

  • Complete pluckNames(users: { id: number; name: string }[]): string[].
  • Return a new array of names.

Examples

  • pluckNames([{ id: 1, name: 'Ada' }, { id: 2, name: 'Lin' }]) → ['Ada', 'Lin']
  • pluckNames([]) → []