issue 117apr 27mmxxvi
est. 2017
Sun, 27 Apr 2026
vol. IX · no. 117
PapersAdda
placement intelligence, since 2017
640+ briefs · 24 campuses · by reservation
verified offers · sourced from r/developersIndia
razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1

JavaScript Coding Questions With Solutions 2026: 24 Solved

8 min read
Interview Questions
Updated: 8 Jun 2026
Aditya Sharma
Aditya's Edit

PapersAdda 2026 Placement Cycle

By Aditya Sharma·Founder & Editor, PapersAdda

What changed in 2026 drives

Mass-recruiter offer letters are flatter for 2026 batch - the 4-5 LPA ASE band has barely budged in three years while inflation eats real wages. Premium tracks (Digital, Pro, Elite, Specialist) are still where the differential lives, and they are entirely test-driven. If you are aiming higher than the default offer, the coding round is not optional pageantry - it is the entire interview.

What I'd actually study for this

  • 01Two solid coding-round answers (1 medium-hard DSA each, with edge-case discussion) > five half-baked ones
  • 02One real project you can defend end-to-end - file paths, design decisions, and what you would change
  • 03One DBMS schema you actually built (not a textbook ER diagram), with at least 3 join-heavy queries written from memory
  • 04Three behavioural STAR stories: failure recovered, conflict handled, ownership taken

Where most candidates trip up

The single biggest mistake is treating company-specific guides as primary prep and DSA as secondary. It is the opposite. Mass recruiters use the test as a filter, but premium tracks at every IT services company use coding to allocate offer band. Spend 70% of prep time on DSA + system fundamentals, 20% on company-specific patterns, 10% on HR rehearsal. Reverse that ratio and you collect the default offer.

Editorial commentary by Aditya Sharma · written for PapersAdda · not generated, not aggregated.

Last Updated: June 2026 | Level: Freshers to Mid-Level | Read Time: ~17 min

JavaScript coding rounds reward fluency with array methods plus the ability to implement primitives like debounce and polyfills from scratch. Candidates report a consistent set of problems across frontend and full-stack screens. This guide gives 24 problems with full working solutions, complexity analysis, and the follow-ups interviewers ask. Every solution is idiomatic and traced for correctness; confirm any method detail on the official MDN documentation.

Pair this with JavaScript Interview Questions for Freshers 2026 and JavaScript Output Questions 2026.


Table of Contents

  1. Arrays (Q1 to Q8)
  2. Strings (Q9 to Q14)
  3. Objects and Utilities (Q15 to Q19)
  4. Polyfills and Advanced (Q20 to Q24)
  5. Complexity Summary
  6. Frequently Asked Questions

Arrays

Q1. Find the maximum in an array. Easy

const max = arr => Math.max(...arr);
// manual:
const maxManual = arr => arr.reduce((m, x) => x > m ? x : m, -Infinity);

Complexity: O(n). Mention the spread call-stack limit for very large arrays, prefer reduce there.


Q2. Remove duplicates from an array. Easy

const dedupe = arr => [...new Set(arr)];

Complexity: O(n) using a Set.


Q3. Flatten a nested array. Medium

const flatten = arr => arr.flat(Infinity);
// manual:
const flattenManual = arr =>
  arr.reduce((acc, x) =>
    acc.concat(Array.isArray(x) ? flattenManual(x) : x), []);

Why two versions: show flat(Infinity), then recursion if built-ins are disallowed.


Q4. Find the intersection of two arrays. Easy

const intersect = (a, b) => {
  const set = new Set(b);
  return a.filter(x => set.has(x));
};

Complexity: O(n + m) with a Set for O(1) lookup.


Q5. Chunk an array into groups of n. Medium

const chunk = (arr, n) => {
  const out = [];
  for (let i = 0; i < arr.length; i += n) out.push(arr.slice(i, i + n));
  return out;
};

Q6. Group array items by a key. Medium

const groupBy = (arr, fn) =>
  arr.reduce((acc, x) => {
    const k = fn(x);
    (acc[k] ||= []).push(x);
    return acc;
  }, {});

Note: ||= lazily initialises the bucket.


Q7. Find the second largest element. Medium

const secondLargest = arr => {
  let first = -Infinity, second = -Infinity;
  for (const x of arr) {
    if (x > first) { second = first; first = x; }
    else if (x > second && x < first) second = x;
  }
  return second;
};

Q8. Rotate an array by k. Medium

const rotate = (arr, k) => {
  k %= arr.length;
  return [...arr.slice(-k), ...arr.slice(0, -k)];
};

Strings

Q9. Reverse a string. Easy

const reverse = s => [...s].reverse().join("");

Note: spread handles surrogate-pair characters better than split("").


Q10. Check for a palindrome. Easy

const isPalindrome = s => {
  const c = s.toLowerCase().replace(/[^a-z0-9]/g, "");
  return c === [...c].reverse().join("");
};

Q11. Count character frequency. Easy

const freq = s =>
  [...s].reduce((m, c) => (m[c] = (m[c] || 0) + 1, m), {});

Q12. Find the first non-repeating character. Medium

const firstUnique = s => {
  const counts = {};
  for (const c of s) counts[c] = (counts[c] || 0) + 1;
  return [...s].find(c => counts[c] === 1) ?? null;
};

Q13. Check if two strings are anagrams. Medium

const isAnagram = (a, b) => {
  const norm = s => [...s].sort().join("");
  return norm(a) === norm(b);
};

Complexity: O(n log n) by sorting; an O(n) count-map version is the optimal follow-up.


Q14. Capitalise the first letter of each word. Easy

const titleCase = s =>
  s.split(" ").map(w => w[0].toUpperCase() + w.slice(1)).join(" ");

Objects and Utilities

Q15. Deep clone an object. Hard

const deepClone = obj => structuredClone(obj);
// manual fallback:
const deepCloneManual = obj =>
  obj === null || typeof obj !== "object"
    ? obj
    : Array.isArray(obj)
      ? obj.map(deepCloneManual)
      : Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, deepCloneManual(v)]));

Note: structuredClone is the modern built-in; the manual version handles the common nested case.


Q16. Merge two objects deeply. Medium

const merge = (a, b) => ({ ...a, ...b });

Follow-up: this is shallow; a deep merge needs recursion on nested object values.


Q17. Implement debounce. Hard

const debounce = (fn, ms) => {
  let t;
  return (...args) => {
    clearTimeout(t);
    t = setTimeout(() => fn(...args), ms);
  };
};

Use: limit how often a search handler fires while the user types.


Q18. Implement throttle. Hard

const throttle = (fn, ms) => {
  let last = 0;
  return (...args) => {
    const now = Date.now();
    if (now - last >= ms) { last = now; fn(...args); }
  };
};

Difference: debounce waits for a pause; throttle caps the rate.


Q19. Curry a function. Medium

const curry = fn =>
  function curried(...args) {
    return args.length >= fn.length
      ? fn(...args)
      : (...rest) => curried(...args, ...rest);
  };

Polyfills and Advanced

Q20. Polyfill Array.prototype.map. Hard

Array.prototype.myMap = function(cb) {
  const out = [];
  for (let i = 0; i < this.length; i++) out.push(cb(this[i], i, this));
  return out;
};

Note: preserve the (value, index, array) callback signature.


Q21. Polyfill Function.prototype.bind. Hard

Function.prototype.myBind = function(ctx, ...preset) {
  const fn = this;
  return function(...later) {
    return fn.apply(ctx, [...preset, ...later]);
  };
};

Q22. Polyfill Promise.all. Hard

const promiseAll = promises =>
  new Promise((resolve, reject) => {
    const out = [];
    let done = 0;
    if (promises.length === 0) return resolve(out);
    promises.forEach((p, i) =>
      Promise.resolve(p).then(v => {
        out[i] = v;
        if (++done === promises.length) resolve(out);
      }, reject)
    );
  });

Key points: preserve order by index, reject on first failure, handle the empty case.


Q23. Memoize a function. Medium

const memoize = fn => {
  const cache = new Map();
  return x => cache.has(x) ? cache.get(x) : (cache.set(x, fn(x)), cache.get(x));
};

Q24. Flatten an object to dot-notation keys. Hard

const flattenObj = (obj, prefix = "") =>
  Object.entries(obj).reduce((acc, [k, v]) => {
    const key = prefix ? `${prefix}.${k}` : k;
    if (v && typeof v === "object" && !Array.isArray(v))
      Object.assign(acc, flattenObj(v, key));
    else acc[key] = v;
    return acc;
  }, {});

Example: {a: {b: 1}} becomes {"a.b": 1}.


Complexity Summary

ProblemApproachComplexity
DedupeSetO(n)
Flattenflat / recursionO(n)
IntersectionSet lookupO(n + m)
Anagramsort or count mapO(n log n) or O(n)
Deep clonestructuredCloneO(n)
Debounce / throttletimer / timestampO(1) per call
Promise.all polyfillindex trackingO(n)

Frequently Asked Questions

What JavaScript coding questions are most asked in 2026?

Candidates report array methods like map, filter, and reduce, string manipulation, flattening nested arrays, implementing debounce and throttle, and writing polyfills for map or bind as the most common coding-round questions.

Should I use built-in array methods or write loops?

Show the idiomatic built-in version first to prove fluency, then be ready to implement the logic manually or as a polyfill if the interviewer asks you to avoid the built-in.

Do frontend interviews ask for polyfills?

Often. Writing a polyfill for Array.prototype.map, Function.prototype.bind, or Promise.all is a popular way to test deep understanding of how the language works under the hood.

What is the difference between debounce and throttle?

Debounce delays execution until activity pauses for a set time, ideal for search-as-you-type. Throttle caps execution to at most once per interval, ideal for scroll or resize handlers.

Why is deep clone harder than spread?

Spread and Object.assign only copy one level, so nested objects stay shared by reference. A true deep clone must recurse (or use structuredClone) so the copy is fully independent.



Confirm any method detail on the official MDN documentation before your interview. This guide reflects candidate-reported patterns and public preparation resources as of June 2026.

Methodology applied to this articlelast verified 8 Jun 2026
Sources used
Public exam-pattern documents, official recruiter pages, and verified candidate reports on r/developersIndia and LinkedIn.
Verification window
Page last edited 8 Jun 2026 by Aditya Sharma. Numbers and patterns sanity-checked against the most recent 2026 cycle drives we tracked.
What we did NOT do
  • No fabricated salary numbers or success rates. If we quote a range, it's sourced.
  • No noun-substituted templates. This article was not generated by swapping company names in a stock prompt.
  • No paid placements, sponsored coaching links, or affiliate-shilled course pushes.
Verification policy: /editorial-standards/. Found something incorrect? Submit a correction - we respond within 48 hours.

Explore this topic cluster

More resources in Interview Questions

Use the category hub to browse similar questions, exam patterns, salary guides, and preparation resources related to this topic.

Paid contributor programme

Sat this this year? Share your story, earn ₹500.

First-person experience reports help future candidates prep smarter. We pay verified contributors ₹500 via UPI per accepted story - with byline.

Submit your story →

Ready to practice?

Take a free timed mock test

Put what you learned into practice. Our mock tests match the 2026 pattern with timer, navigator, reveal, and score breakdown. No signup.

Start Free Mock Test →

Related Articles

More from PapersAdda

Share this guide: