We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
An easy frontend problem, graded against 5 test cases (2 of them hidden).
React and browser-platform problems - hooks, event handling, and rendering behaviour.
Reach for it when you see: A component, hook, or DOM-behaviour question rather than an algorithm.
More Frontend problems →Interviewers ask this because it is small and still exposes whether you know the difference between an *attribute* and a *property*, and whether you keep accessibility state in sync with the visual state:
- `aria-selected` is an attribute - screen readers read it; `setAttribute` with a string.
- `hidden` is a reflected boolean property; `panel.hidden = true` adds the attribute, `false` removes it.
- Roving tabindex (`0` on the active tab, `-1` on the rest) makes the tab list a single tab stop; arrow keys move between tabs.
Reading state back from the DOM at the end (rather than returning what you *think* you set) is how you would write a test for this in the real codebase too.
Time: O(tabs).
The full reference solution in every supported language stays in the editor above - reveal it there once you have had a real attempt.
Read off this problem's own test suite, so these are the cases a submission actually has to survive.
These apply to the pattern as a whole, not just this problem.