Octagram Labs
JavaScriptData StructuresReact
Sign in
← Back to problems

Extract Keys

Rendering Listseasy

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

Implement `getKeys(items)` returning the `id` of each item, suitable for React list keys.

Sample tests

Input: getKeys([{"id":3},{"id":7}])
Output: [3,7]
Input: getKeys([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Using array index as a key when items reorder, which breaks reconciliation; prefer stable ids.

Learning resources

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

Extracting stable ids gives React keys that survive reordering, so it can match elements across renders correctly.

Loading...
⌘/Ctrl + Enter

Run your code to see results.