10 Common JavaScript Interview Questions (and Answers)
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.
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
- Create a variable
sum = 1
which will store the missing number and a counter variablec = 2
. - Traverse the array from start to end.
- Update the value of sum as
sum = sum — array[i] + c
and updatec
asc++
. - 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.
Learn More
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK