Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Declarative Filter then Map

Modern JavaScriptmedium

Course · Section 17: Modern JavaScript Development: Modules, Tooling, and Functional · Lecture 294: Declarative and Functional JavaScript Principles

Implement `activeNames(users)` returning the names of users whose `active` is true, using `filter` then `map`.

Sample tests

Input: activeNames([{"name":"A","active":true},{"name":"B","active":false}])
Output: ["A"]
Input: activeNames([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Doing both in one loop is fine but less declarative.
Approach & explanation (try first)

Filtering the active users then mapping to names reads as a clear data transformation.

Loading...
⌘/Ctrl + Enter

Run your code to see results.