Javascript developer Interview Questions
994
Javascript Developer interview questions shared by candidates
Convert : person_First_Name to personFirstName
4 Answers↳
var name = "person_First_Name"; var d = name.split("_").join(""); console.log(d); Less
↳
'Person_First_Name'.split("_").join("");
↳
function convertor(name){ let result="" splittedNames=name.split("_") splittedNames.map(a=>{ result+=a }) console.log(result); } convertor("Person_First_Name") Less

4)write program to remove duplicate in an array
4 Answers↳
function removeDuplicateUsingSet(arr){ let unique_array = Array.from(new Set(arr)) return unique_array } Less
↳
var chars1 = ['A', 'B', 'A', 'C', 'B']; var uniqueChars2 = []; chars1.forEach((c) => { if(!uniqueChars2.includes(c)) { uniqueChars2.push(c); } }) Less
↳
for(let i=0; i

How will you put a child div in center to outer container?
2 Answers↳
{display:block; margin:0 auto;}
↳
Margin : auto

6) what will be the value of a and b if Var a = 5 +7 + “8” Var b = “8”+5+7
3 Answers↳
a=128,b=857
↳
a = 128 b= 857
↳
a=128 b=124



To reverse a string without using reverse keyword.
2 Answers↳
Can use the loop in structure
↳
Str.split('').reverse().join('')

Using a nested for() loop is inefficient, can you do it more efficient than the native String.indexOf() method? Without nesting for loops or recursion.
2 Answers↳
Convert the strings to objects with each word being added as a property to speed up the lookup. I had heard of this technique but never done it myself. Less
↳
sort the words will be done in n Log n . for each word in 1st string do binary search on other string which will run in n log n so overall complexity will be n log n. Less

Online : 1) Nearest to zero element in an array 2) Longest prefix program 3) single loop reversal of string online questions require you to fill the logic only , not to write the entire program Pen paper : input =['acr', 'bat','car','atb','rca','rac','xyz'] desired output: [ ['acr','car','rca','rac'], ['bat','atb'],['xyz']] i.e grouping of psuedonyms .
1 Answers↳
let arr = ["acr", "bat", "car", "atb", "rca", "rac", "xyz"]; let flag = 0; let result = []; let pos = 0; for (let i = 0; i < arr.length; i++) { if (!result.flat().includes(arr[i])) { result.push([arr[i]]); pos += 1; for (let j = i + 1; j < arr.length; j++) { if (arr[i].length === arr[j].length) { for (let k = 0; k < arr[i].length; k++) { if (arr[j].includes(arr[i][k])) { flag += 1; } } if (flag == arr[i].length) { result[pos - 1].push(arr[j]); } flag = 0; } } } } console.log(result); Less
