BeginnerCoder

Lesson 12 — Computed with filter

Filtered views of your data

A computed can return a whole new array — for example only the finished todos — built with filter. The original array stays untouched, and the filtered view updates by itself when any todo changes.

const cheap = computed(() => products.value.filter((p) => p.price < 10))

Why it matters: tabs like "All / Active / Done" are just different computed filters over one list.

Want it another way?
Task

Make done a computed list of finished todos. The preview should list Buy milk and Read, and say "2 of 3 finished".

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.