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 6 test cases (3 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 →The trap is `list.innerHTML += `<li>${item}</li>`` - it re-parses the whole list on every iteration (quadratic), and an item like `<img onerror=...>` becomes live markup. This is the exact bug class behind most DOM XSS.
Creating an element and assigning `textContent` treats the string as text no matter what it contains. When the grader reads `innerHTML` back, the serializer escapes `<`, `>` and `&` - which is why the expected output for `"<b>x</b>"` is `<b>x</b>`.
For large lists, build into a `DocumentFragment` and append once, so the layout engine sees a single mutation.
Time: O(n). Space: O(1) beyond the nodes themselves.
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.