StaffCoder
TypeScript
Vanilla TypeScriptTypeScript 7.0
6 modules · 24 challengesSign up
Module 2 · Events & Event Handling

Filter Toolbar

easy0%0 of 1 solved

Problem statement

A product listing whose filter controls are wired to nothing. A search field, a category select, and an in-stock checkbox must together decide which products from an in-memory array are shown, using Vanilla TypeScript and standard DOM APIs.

Demo

The page, styles, mock data, and toolbar markup are already scaffolded and wired. Only the initializeFilterToolbar function is missing — implement it in src/js/filterToolbar.ts so every test passes. Do not edit any other file.

What to implement

  • Make each of the three controls filter the products that are shown: the search field by name, the select by category, and the checkbox by stock.
  • Update the page immediately whenever any control changes.
  • Show the products that satisfy every control at once, not just the one that changed last.
  • Treat a control with no value applied as placing no restriction of its own, so clearing one filter leaves the others in effect.
  • Show one row per product that is displayed, holding that product's name.
  • Show how many products are displayed, keeping that number consistent with the rows on the page.
  • Show the no-matches message only when nothing is displayed, with no rows on the page while it is visible.
  • Leave the product array you were given unchanged, and leave the controls and the rest of the page as you found them.
  • Everything shown must come from the product array you were given — nothing should be hardcoded.

More in Events & Event Handling

See the module
Quantity StepperWire increment / decrement buttons to a numeric display bound between 1 and a supplied maximum, disabling each button at its bound. Values typed directly into the field are clamped on blur, and a change callback fires only when the value actually changes — not on repeat writes of the same number.0%0 of 1 solvedeasyDismissible DialogOpen and close a dialog element, closing on the close button, on Escape, and on a click of the backdrop but not the panel. Focus moves into the dialog on open and returns to the element that opened it on close, and the key listener is removed on close so a later Escape press does nothing.0%0 of 1 solvedeasyLive Character CounterUpdate a counter on every input event showing characters used against a maximum, add a warning class within the last 20 chars, and block further input beyond the limit while still allowing deletion. Pasting an over-length string truncates to the limit. Use the input event, not keydown.0%0 of 1 solvedeasy

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.