Scriptdrill

JavaScript interview questions: code them, run them, pass the hidden tests

JavaScript interviews rarely ask for an algorithm from a textbook. They ask for the utility you would write at work: group these records, flatten this object, debounce this handler, retry this request, limit how many promises run at once. Every question below opens an editor with examples and runs your function against hidden tests, including the edge cases an interviewer will ask about.

What front-end and full-stack screens ask

  • Array and object manipulation: group by, count by, unique by, chunk, zip, flatten, pick, multi-key sort, deep merge.
  • Strings and dates: slugify, truncate, format money, parse a query string, add days, days between dates, format a duration.
  • Data shaping: CSV to objects, totals per key, pivot to a lookup, top N with ties, running totals, nested paths, deep equality, left join.
  • Functions and async: debounce, memoize, once, pipe, sleep, retry with backoff, a timeout wrapper, tasks in sequence, Promise.all with a concurrency limit.
  • The follow-ups: what about an empty array, a missing key, null, ties, Unicode, a promise that never settles.

Warm-up: arrays, strings and numbers

These are the questions a screen opens with. They look trivial, and the hidden tests are where candidates fail: an empty list, negative numbers, a word with no vowels, bounds that are equal.

  1. Total of a list Free
  2. Items in stock Free
  3. Full names Free
  4. Has every tag Free
  5. Reverse the words Free
  6. Capitalize each word Pro
  7. Count the vowels Pro
  8. Clamp a number Pro
  9. Range of numbers Pro

Arrays and objects

Group by and unique by are the two most asked utility questions in JavaScript interviews; chunk, zip and flatten follow. Deep merge is the one that separates people who understand references from people who do not.

  1. Group by a field Pro
  2. Count by a field Pro
  3. Remove duplicates by a field Pro
  4. Split into chunks Pro
  5. Zip two arrays Pro
  6. Flatten one level Pro
  7. Pick some keys Pro
  8. Sort by several keys Pro
  9. Merge settings Pro

Strings and dates

Formatting questions test attention to edge cases: trailing hyphens in a slug, an ellipsis that fits within the limit, negative amounts, repeated query keys, month lengths and leap years.

  1. Make a URL slug Pro
  2. Truncate with an ellipsis Pro
  3. Format money Pro
  4. Parse a query string Pro
  5. Align a text table Pro
  6. Add days to a date Pro
  7. Days between two dates Pro
  8. Format a duration Pro
  9. Last day of the month Pro

Data shaping

The questions a data-heavy front end or a Node service needs: parse CSV with quoted fields, totals per customer, top N with ties, running totals, read a nested path safely, deep equality, flatten a nested object into dotted keys, left join two lists.

  1. CSV text to objects Pro
  2. Totals per customer Pro
  3. Pivot rows into a lookup Pro
  4. Top N with ties Pro
  5. Running totals Pro
  6. Read a nested value by path Pro
  7. Deep equality Pro
  8. Flatten a nested object Pro
  9. Left join two lists Pro

Async and higher-order functions

Implement debounce, memoize, once, pipe and sleep from scratch; then retry with backoff, a timeout wrapper, tasks run in sequence, and the question senior screens love: Promise.all with a concurrency limit.

  1. Sleep with a Promise Pro
  2. Retry a failing call Pro
  3. Promise.all with a concurrency limit Pro
  4. Debounce Pro
  5. Memoize Pro
  6. Run only once Pro
  7. Pipe functions together Pro
  8. Timeout wrapper Pro
  9. Run tasks in sequence Pro

How the questions are checked

Your function runs in your browser against the visible examples and a set of hidden tests. The feedback names the first failing case with the input and the output you returned, which is the same conversation you will have with an interviewer. After two attempts the hidden inputs are revealed, and a reference solution opens.

Code the questions

Five exercises are free without an account. Pro unlocks all 45, with hidden tests, hints, reference solutions and progress saved to your account.

Start practicing free

Questions

Which JavaScript version?

Modern JavaScript as it runs in current browsers and Node: ES modules syntax is not needed, but arrow functions, destructuring, spread, Map and Set, async/await and optional chaining all work.

Are these LeetCode-style algorithm questions?

No. They are the practical utility questions front-end and full-stack interviews actually ask. For data structures and algorithms use a dedicated site; for the JavaScript you will be asked to write on the spot, this set is closer.

Can I use TypeScript?

The editor runs JavaScript. Write plain JavaScript; the solutions are easy to annotate afterwards if you want to practice types.

Do I need Node installed?

No. Everything runs in the browser, including the async exercises, which use real timers and promises.