Running a machine-coding round · mid
Vanilla JS vs React rounds
In a vanilla round, keep one state object, write a render step that updates the DOM from state, use event delegation, wrap each widget in a module or class so several instances work, and set text with textContent. In a React round, you are judged on hooks, state design and component APIs.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Who asks vanilla: Flipkart machine coding (plain HTML/CSS/JS, modular), Atlassian's Karat screen (React not allowed), CRED's typeahead, Microsoft's full-page search.
- Vanilla structure: state → render() (or targeted DOM updates) → handlers change state, then render. One listener on the container with event.target.closest('[data-id]') (event delegation) instead of one per item.
- DOM APIs: createElement, textContent (never innerHTML with user data), DocumentFragment for batch inserts, classList, dataset, addEventListener options { once, passive, signal } (abort a controller to remove many listeners).
- No globals: ES modules, or a factory/class per widget so two instances on one page don't share state (Front End Interview Handbook tip).
- Performance: batch DOM writes, read layout before writing to avoid thrashing, requestAnimationFrame for animation, debounce input.
- React: function components and hooks, minimal state, stable keys, effects with cleanup, custom hooks for logic (useDebounce, useFetch), controlled/uncontrolled APIs.
- Both: semantic HTML, keyboard support, plain CSS (flex/grid) without frameworks.
The red pen
Common traps: mistake → fix
Mistake: innerHTML with user text
Fix: XSS; use textContent or escape.
Mistake: A listener per list item
Fix: memory and leaks; delegate to the container.
Mistake: Module-level variables for widget state
Fix: a second instance breaks.
Mistake: Re-render the whole list on every keystroke in vanilla
Fix: update only what changed or debounce.
Easy to hard
Questions interviewers ask, easy to hard
- Build this without React. How do you organise the code?
- What is event delegation and why use it here?
- Why is innerHTML risky?
- How would you support two instances of this widget on one page?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.