▸case-01 Our backend service has a bug in its asynchronous pipeline where file system operations fail under load without proper exception catching. Please debug the script provided below, resolve the issue, and output the fully corrected code along with a short section explaining what caused the failure and how it was resolved. | fail→pass | 19,329 | 10,437 | -46% | 1 | 1 | 0% | 3,522 | 1,928 | -45% | 0 | 0 | — |
▸case-02 We need a function that accepts an array of user objects and returns them sorted by score descending, but the original array must remain untouched so other parts of the application reading the cache aren't mutated. A colleague suggested calling .sort() directly on the array. | pass→pass | 8,757 | 4,781 | -45% | 1 | 1 | 0% | 1,353 | 1,052 | -22% | 0 | 0 | — |
▸case-03 In our transaction log, we need to find the most recent matching transaction that satisfies a predicate. The team usually writes a loop or reverses the entire array with .reverse().find(). Write a JavaScript snippet to efficiently fetch the last matching element without mutating or reversing the original array. | pass→pass | 8,604 | 5,437 | -37% | 1 | 1 | 0% | 1,508 | 1,163 | -23% | 0 | 0 | — |
▸case-04 We need to fetch profile data for three independent user IDs (userA, userB, userC) in a Node.js route. The current draft uses three sequential await calls: `const a = await fetchUser(idA); const b = await fetchUser(idB); const c = await fetchUser(idC);`. Optimize this script to execute the network requests concurrently. | pass→pass | 3,951 | 5,217 | +32% | 1 | 1 | 0% | 859 | 1,272 | +48% | 0 | 0 | — |
▸case-09 When calling an external REST API with Node.js `fetch()`, we want to abort the request if it takes longer than 5000ms. Refactor a standard fetch call to cancel the underlying HTTP request on timeout without resorting to `Promise.race` hacks. | pass→fail | 6,910 | 8,063 | +17% | 1 | 1 | 0% | 1,385 | 1,747 | +26% | 0 | 0 | — |
▸case-05 We are writing an ESM module (`.mjs`) in Node.js 18+ that needs to load database credentials asynchronously before exporting the database client. A legacy developer recommended wrapping everything in `(async () => { ... })()`. | pass→pass | 12,628 | 9,089 | -28% | 1 | 1 | 0% | 1,938 | 1,813 | -6% | 0 | 0 | — |
▸case-06 We are writing a Node.js file processing utility. Developers are currently using `fs.readFileSync` inside an HTTP handler, causing event loop blocking under heavy traffic. Refactor this to use modern non-blocking promise-based file system APIs in Node.js. | pass→pass | 10,194 | 12,374 | +21% | 1 | 1 | 0% | 2,275 | 2,663 | +17% | 0 | 0 | — |
▸case-07 Given an array of inventory items with a `category` property, we need to group them by category into an object mapping category names to arrays of items. Write a modern ES2024 JavaScript function to accomplish this without manually writing a `.reduce()` or `for` loop initialization. | pass→pass | 4,822 | 5,630 | +17% | 1 | 1 | 0% | 889 | 1,388 | +56% | 0 | 0 | — |
▸case-08 We have an immutable state array in a JS application and need to produce a new array with an updated element at index `i`. Writing `arr[i] = newValue` mutates state directly. Show the modern ES2023 non-mutating array method for updating an element at a specific index. | pass→pass | 4,135 | 4,317 | +4% | 1 | 1 | 0% | 853 | 1,042 | +22% | 0 | 0 | — |
▸case-14 We need to stream a compressed file from disk, decompress it, and pipe it to an HTTP response stream in Node.js. Developers previously manually listened to `'data'` and `'error'` events on streams, leading to memory leaks when errors occurred. Write the modern Node.js stream utility approach. | pass→pass | 8,444 | 8,223 | -3% | 1 | 1 | 0% | 1,811 | 1,780 | -2% | 0 | 0 | — |
▸case-10 Design a Node.js ES2022 JavaScript class `BankAccount` with a balance attribute that cannot be accessed or modified from outside the class instance, replacing legacy `_balance` conventions. | pass→pass | 7,811 | 9,520 | +22% | 1 | 1 | 0% | 1,609 | 2,246 | +40% | 0 | 0 | — |
▸case-11 When rethrowing a caught low-level network error in Node.js, we want to wrap it in a higher-level `DatabaseError` while retaining the original low-level exception stack trace and context. Show how to attach the original error using standard ES2022 Error options. | pass→pass | 6,058 | 13,008 | +115% | 1 | 1 | 0% | 1,296 | 1,908 | +47% | 0 | 0 | — |
▸case-12 We need to import a local `config.json` file inside a Node.js ES module file. Previously people used `fs.readFileSync` and `JSON.parse`. Show how to import the JSON file directly using modern Node.js ESM syntax. | pass→pass | 6,821 | 5,570 | -18% | 1 | 1 | 0% | 1,261 | 1,222 | -3% | 0 | 0 | — |
▸case-13 We need to produce a copy of an array with elements removed and inserted at a given index without mutating the original array. Show how to perform non-mutating splicing in ES2023. | pass→pass | 6,320 | 6,222 | -2% | 1 | 1 | 0% | 1,196 | 1,389 | +16% | 0 | 0 | — |
▸case-15 We are building a cache in JavaScript where cached items should not prevent garbage collection if no other reference exists. Write code using standard ECMAScript features to hold weak references to object values. | pass→pass | 17,427 | 13,828 | -21% | 1 | 1 | 0% | 2,787 | 3,204 | +15% | 0 | 0 | — |
▸case-16 We have an array of asynchronous API calls where some endpoints might fail (404/500), but we want to collect results from all calls (both fulfilled and rejected) without short-circuiting on the first failure. Write the JavaScript Promise method. | pass→pass | 5,464 | 7,373 | +35% | 1 | 1 | 0% | 1,231 | 1,541 | +25% | 0 | 0 | — |
▸case-17 We need to create a deep clone of a complex JS object containing `Date` objects and nested arrays. Developers are using `JSON.parse(JSON.stringify(obj))` which corrupts Date objects into strings. Provide the standard modern JavaScript deep cloning solution. | pass→pass | 7,114 | 9,437 | +33% | 1 | 1 | 0% | 1,409 | 1,781 | +26% | 0 | 0 | — |
▸case-18 Generate a cryptographically secure V4 UUID string inside a Node.js 18+ module. Do not install or import third-party npm packages like `uuid`. | pass→pass | 6,480 | 5,713 | -12% | 1 | 1 | 0% | 977 | 1,205 | +23% | 0 | 0 | — |
▸case-19 Replace all occurrences of a literal substring inside a string without writing a regular expression with global flags `/g`. | pass→pass | 9,511 | 5,370 | -44% | 1 | 1 | 0% | 1,978 | 1,316 | -33% | 0 | 0 | — |
▸case-20 A computationally intensive CPU-bound task (calculating prime numbers) is blocking the Node.js event loop and delaying incoming HTTP requests. Show how to offload this CPU-heavy computation to a separate background thread in Node.js. | pass→pass | 12,988 | 15,888 | +22% | 1 | 1 | 0% | 2,928 | 3,115 | +6% | 0 | 0 | — |
▸case-21 Write a Python script using `asyncio` and `aiohttp` to fetch multiple URLs concurrently and save their contents to disk. | pass→pass | 12,907 | 13,262 | +3% | 1 | 1 | 0% | 2,585 | 3,197 | +24% | 0 | 0 | — |
▸case-22 Configure a `tsconfig.json` file for a strict TypeScript 5.0 project targeting ESNext with module resolution bundler, and explain how `noImplicitAny` affects interface declarations. | pass→pass | 13,542 | 25,063 | +85% | 1 | 1 | 0% | 2,728 | 2,164 | -21% | 0 | 0 | — |
▸case-23 Create a CSS stylesheet for a responsive navigation bar that uses flexbox, centering items vertically and spacing them evenly horizontally. | pass→pass | 19,713 | 11,642 | -41% | 1 | 1 | 0% | 2,136 | 2,944 | +38% | 0 | 0 | — |