Skip to main content

Component Logic Check

Challenge on lesson: Checkpoint: Component Logic

Implement three component-logic helpers: 1. findActionable(target, selector) RETURNS the first element in the chain target, target.parent, target.parent.parent, ... matching selector (elements have a matches(sel) method), or null. 2. reduceTabs(state, action) RETURNS a NEW { active, count } object. Actions: { type: "select", index } clamps 0..count-1, { type: "next" } and { type: "prev" } wrap around. The input state must not be mutated. 3. debounce(fn, ms) RETURNS a debounced wrapper. Calls inside the quiet window cancel the pending one; after ms of quiet the LAST call's arguments are used.

Difficulty: intermediate

Back to lesson: Checkpoint: Component Logic