Octagram Labs
JavaScriptData StructuresReact
Sign in
← Back to problems

Active Count

Derived Stateeasy

Course · Section 11: Working With Arrays · Lecture 160: The reduce Method

Implement `activeCount(todos)` returning how many todos are not done.

Sample tests

Input: activeCount([{"done":false},{"done":true}])
Output: 1
Input: activeCount([])
Output: 0

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Treating missing done as done; undefined is falsy so it counts as active here.

Learning resources

  • React: Choosing the State Structure
Approach & explanation (try first)

Active items are simply those not done, computed from the list rather than tracked separately.

Loading...
⌘/Ctrl + Enter

Run your code to see results.