Coinbase frontend engineer interviews emphasise JavaScript, DOM manipulation, CSS, accessibility, browser APIs, and UI component architecture.
KnowledgeBaseSystem that stores articles with CRUD operations. The system operates entirely...Input: Graph (nodes and edges)createAccountManager(initialBalance: number): { deposit: Function; withdraw: Function; getBalance: Function; } that returns an object with methods to deposit, withdraw, and getBalance. Using closures, ensure that the balance is encapsulated and not directly accessible.deposit(amount: number): void — Adds an amount to the balance.withdraw(amount: number): void — Reduces the balance by the specified amount if sufficient funds are available.getBalance(): number — Returns the current balance.Example 1:const account = createAccountManager(100); account.deposit(50); account.getBalance();150account.withdraw(30); account.getBalance();120initialBalance is a non-negative integer.simulateEventLoop(tasks: Array<Promise<void>>): void that takes an array of promises representing asynchronous tasks and executes them in a way that reflects the behavior of the event loop. Ensure that any tasks scheduled in the event loop (using setTimeout or similar) are executed only after the current stack is clear.simulateEventLoop(tasks: Array<Promise<void>>): void — Simulates the event loop and executes tasks in order.Example 1:simulateEventLoop([Promise.resolve(), new Promise((res) => setTimeout(res, 100)), Promise.resolve()])Executed (in order: resolve, wait, resolve)simulateEventLoop([new Promise((res) => setTimeout(res, 50)), Promise.resolve(), new Promise((res) => setTimeout(res, 20))])Executed (in order: wait 50ms, resolve, wait 20ms)Constraints:1 <= tasks.length <= 10^4ClientRouter that manages different routes in a single-page application. Users will navigate between different components based on the URL without refreshing the page.addRoute(path: string, component: Function): void — Adds a new route along with its corresponding component.navigate(path: string): void — Navigates to the given path and renders the associated component.getCurrentPath(): string — Returns the current path the user is on.Example 1:const router = new ClientRouter(); router.addRoute('/home', HomeComponent); router.navigate('/home');Rendered HomeComponent/home, the associated component is rendered.Example 2:router.addRoute('/about', AboutComponent); router.navigate('/about');Rendered AboutComponentConstraints:VirtualDOM that can create, update, and render a lightweight representation of a real DOM. This is vital to reduce expensive layout recalculations and improve responsiveness.createElement(tag: string, props: Object, children: Array<VirtualNode>): VirtualNode — Create a new Virtual Node.update(oldNode: VirtualNode, newNode: VirtualNode): VirtualNode — Update an old node to match a new one and return the updated Virtual Node.render(node: VirtualNode): HTMLElement — Convert a Virtual Node back into a real DOM HTMLElement.Example 1:const vNode = virtualDOM.createElement('div', { className: 'container' }, []);Virtual Node createdExample 2:virtualDOM.update(oldVNode, newVNode);Updated Virtual NodeConstraints:Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free