Octagram Labs
JavaScriptData StructuresReact
Sign in
← Back to problems

Visible Items Only

Rendering Listseasy

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

Implement `visibleItems(items)` returning only the items whose `visible` property is true.

Sample tests

Input: visibleItems([{"id":1,"visible":true},{"id":2,"visible":false}])
Output: [{"id":1,"visible":true}]
Input: visibleItems([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Returning the same array when nothing is filtered, which is fine, but mutating it is not.

Learning resources

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

filter keeps only items whose visible property is truthy, producing a new array for rendering.

Loading...
⌘/Ctrl + Enter

Run your code to see results.