Pending tasks filter
The "To do" tab shows the result of pendingTasks(). Users say it lists the tasks they already finished. Find the bug.
interface Task { id: string; title: string; done: boolean;} export function pendingTasks(tasks: Task[]): Task[] { return tasks.filter((task) => task.done);}Show answer
line 8 · Logic inverted
filter keeps the items for which the callback returns true, so this keeps the completed tasks. Pending tasks are the ones where done is false.
return tasks.filter((task) => !task.done);Interview follow-up: A quick unit test with one done and one pending task catches this instantly; say so.