Command Palette

Search for a command to run...

Hectal
Phase 9: Events
JavaScript · Exercise 5 of 6 PreviousNext
Intermediate

A debounced filter

Typing in #q should filter the fruit list: items that don't contain the typed text (ignoring capitals) are hidden with the hidden property; an empty box shows every item.

Debounce it: the filtering must happen 300 ms after the user stops typing, not on every key. Write a debounce(fn, delay) function and use it.

What Check tests

  1. After a pause, only matching items are shown
  2. Capitals don't matter
  3. It waits: nothing changes straight after typing
  4. Fast typing filters once, for the final text
  5. An empty box shows every item again

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.