Skip to content

Instantly share code, notes, and snippets.

@hyber1z0r
Created August 10, 2020 19:47
Show Gist options
  • Save hyber1z0r/fae9047659b6a2372d0242dadce17945 to your computer and use it in GitHub Desktop.
Save hyber1z0r/fae9047659b6a2372d0242dadce17945 to your computer and use it in GitHub Desktop.
type Todo = {
id: number;
title: string;
completed: boolean;
}
const todos: Todo[] = [
{ id: 1, title: 'Buy nachos', completed: false },
{ id: 2, title: 'Buy avocado', completed: true },
{ id: 3, title: 'Buy ground beef', completed: false },
];
const completedTodos = todos.filter((todo) => todo.completed);
console.log(completedTodos); // [{ id: 2, title: 'Buy avocado', completed: true }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment