10 Common JavaScript Interview Questions (and Answers)

Ravi Sharma
Bits and Pieces
Published in
3 min readMar 29, 2022

--

1. Find the frequency of elements in array

Method 1: Using Reduce method of array

Method 2: Using an Object

2. Group items on the basis of age of given array of object

3. Program to check a string with balanced brackets.

4. Find the pairs of array element for which sum is equal to given target value (Two Sum Problem)

5. Find the missing number from unsorted array with O(n) complexity

Algorithm

  1. Create a variable sum = 1 which will store the missing number and a counter variable c = 2.
  2. Traverse the array from start to end.
  3. Update the value of sum as sum = sum — array[i] + c and update c as c++.
  4. Print the missing number as a sum.

6. Find the missing number from sorted array with O(n) complexity

7. Find the nth largest element in a sorted array

8. Remove duplicates from an array and return unique values in O(n) complexity.

9. Print all duplicate elements of an array

10. Collect books from array of objects and return collection of books as an array

I hope you have found this quick list of common JavaScript interview questions and answers useful. Thank you for reading!

Build Apps with reusable components, just like Lego

Bit’s open-source tool helps 250,000+ devs to build apps with components.

Turn any UI, feature, or page into a reusable component — and share it across your applications. It’s easier to collaborate and build faster.

Learn more

Split apps into components to make app development easier, and enjoy the best experience for the workflows you want:

Micro-Frontends

Design System

Code-Sharing and reuse

Monorepo

--

--