Octagram Labs
JavaScriptData StructuresReact
Sign in
← Back to problems

Map to Labels

Rendering Listseasy

Course · Section 11: Working With Arrays · Lecture 157: The map Method

Implement `toLabels(items)` returning the `name` of each item, ready to render as text.

Sample tests

Input: toLabels([{"name":"a"},{"name":"b"}])
Output: ["a","b"]
Input: toLabels([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Assuming every item has a name without checking the data shape.

Learning resources

  • React: Rendering Lists
Approach & explanation (try first)

map transforms the list of objects into a list of their name strings, ready to render as text or option labels.

Loading...
⌘/Ctrl + Enter

Run your code to see results.