4

10 Common JavaScript Interview Questions (and Answers)

 2 years ago
source link: https://blog.bitsrc.io/most-important-javascript-coding-challenge-aa14c956d2df
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

10 Common JavaScript Interview Questions (and Answers)

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. Find the longest word in a sentence

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

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 composable web applications

Don’t build web monoliths. Use Bit to create and compose decoupled software components — in your favorite frameworks like React or Node. Build scalable and modular applications with a powerful and enjoyable dev experience.

Bring your team to Bit Cloud to host and collaborate on components together, and speed up, scale, and standardize development as a team. Try composable frontends with a Design System or Micro Frontends, or explore the composable backend with serverside components.

Give it a try →

https://cdn-images-1.medium.com/max/800/1*ctBUj-lpq4PZpMcEF-qB7w.gif

Learn More


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK