Codington
0 of 6 problems solved0%

Filter Completed Todos

Given an array of todos with shape { id: number; title: string; completed: boolean }, return a new array containing only the completed ones. This reinforces filtering arrays of objects and returning a new array without mutation.

Your Task

  • Complete completedTodos(todos: { id: number; title: string; completed: boolean }[]): { id: number; title: string; completed: boolean }[].
  • Do not mutate the input array.

Examples

completedTodos([{ id: 1, title: 'A', completed: true }, { id: 2, title: 'B', completed: false }])[{ id: 1, title: 'A', completed: true }]