All practice tasks

Coding (Platform)

End-to-end facet contract

express + react · Easy · form contract

A browser and API disagree at the end-to-end facet contract boundary. A catalog screen receives available facet values after every search. The current state boundary keeps selections that no longer exist, so the UI announces filters that cannot affect the visible result.

Task

Repair the shared browser-to-service contract. Normalize the query, remove unavailable selections, preserve the order of surviving selections, and derive the active-filter count used by the supplied screen adapter.

Contract

Input is {query, selected, available}. Return {query, selected, activeCount}. Values are strings; matching is exact after trimming each selected value. Duplicate selections keep their first position.

Acceptance criteria

  • Trim the query.
  • Drop blank, duplicate, and unavailable selections.
  • Keep the first-seen order.
  • Set activeCount to selected.length plus one when query is non-empty.
  • Keep browser-visible state consistent with the canonical service result.

Constraints

  • Do not mutate caller-owned input.
  • Keep the supplied framework adapter and public contract unchanged.
  • Add candidate tests for at least one boundary not covered by the public cases.

Editable files

  • src/repair.js — Task-specific state or service boundary
  • tests/candidate.test.js — Candidate-authored regression

What this task practices

End-to-end facet contract is a coding (platform) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as easy difficulty. It focuses on State Modeling, Regression Testing, Technical Reasoning. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.