JavaScript is changing every year. There are always new libraries, new frameworks and new things around it. Every year new developers are coming to learn this language and the jobs are increasing so as the interviews.
This post contains some practical and commonly asked coding problems that can be found in any technical interviews. So be not surprised while facing them.
Remove duplicate element from an array
Using Array.filter
method, check each element's index is equal to the indexOf
value of the array.
Or in ES6 using set:
Reverse a string without native methods
Given a string, print the reverse of the string (ex: javascript
becomes tpircsavaj
).
Without native methods:
Using recursion:
Find the missing number
Given a unsorted array of numbers 1 to 100 excluding one number, find the missing number.
The sum of a linear series of n
numbers is equal to n*(n+1)/2
.
Permutations of a string
Get all permutations of a string
Check sum of two
From a unsorted array, check whether there are any two numbers that will sum up to a given number.
Another way of doing, have an object where we will store the difference of sum and element. And then when we get to a new element and if we find the difference is the object, then we have a pair that sums up to the desired sum.
Brackets match
For the given string, determine if the strings of brackets in the input is valid or invalid by these criteria.
"([)]" // false
"()" // true
The solution is
This post contains only a handful of examples from our recently published app JS Code Samples. This app contains many examples varying from variable scope to coding problems like these. You can download the app from the below link.
Top comments (0)