Web Development Engineer Interviews

Web Development Engineer Interview Questions

95

Web Development Engineer interview questions shared by candidates

Top Interview Questions

Sort: Relevance|Popular|Date
Amazon
Web Development Engineer was asked...February 25, 2017

Implement Sum(3)(4)(5)=12 with javascript

17 Answers

const Sum = a => b => c => a + b + c;

``` // Lexically nested function definitions defined within enclosing function function Sum(arg0) { function Inner1(arg1) { function Inner2(arg2) { return arg0 + arg1 + arg2; } return Inner2; } return Inner1; } console.log(Sum(3)(4)(5)); ``` Less

var sum=0; // global variable function Sum(num){ sum=num+sum; return Sum; } Sum(3)(4)(5); Less

Show More Responses
Amazon

Vertically and horizontally center an element on the screen using css.

8 Answers

#center{width: 100px; height: 50px; position: fixed; top: 0; left: 0; right: 0; bottom: 0; margin: auto;} Less

wrong answer. u need to also margin it negative

. container{ Position : absolute; Width : 200px; Top : 50℅; Left : 50℅; Transform : translate(-50℅) } Less

Show More Responses
Amazon

Take two arrays and compare them to find duplicates. Only list each duplicate once.

6 Answers

The most upvoted answer on this has a run time complexity of O(m * n) where m and n are the arrays. This is solvable in O(n) by using a hash map, by sacrificing space for complexity: var Array1 = ["a", "b", "c", "d", "e", "f", "c"]; var Array2 = ["c", "x", "y", "f", "c"]; let hash = {}; let result = []; // loop over the largest for (let i = 0; i < Array1.length; i++) { if (!hash[Array1[i]]) { hash[Array1[i]] = 1; } } for (let i = 0; i < Array2.length; i++) { if (hash[Array2[i]]) { result.push(Array2[i]); delete hash[Array2[i]]; } } console.log(result); Less

var Array1 = ["a", "b", "c", "d", "e", "f"]; var Array2 = ["c", "x", "y", "f"]; Array1 = Array1.filter(function(val) { return Array2.indexOf(val) !== -1; }); Less

I think that the last solution suggested might still return duplicates. For example if array1 = [1,2,3] and array2 = [2,2,2] we will get the result of [2,2]. This is another solution in O(n) - function findDuplicates(arr1, arr2) { var dict = {}; var duplicates = {}; for (i = 0; i < arr1.length; i++ ) { dict[arr1[i]] = 1; } for (i = 0; i < arr2.length; i++ ) { if (dict[arr2[i]]) { duplicates[arr2[i]] = arr2[i]; } } return Object.values(duplicates); } Less

Show More Responses
Amazon

How would you implement integer division if your language did not offer it.

5 Answers

#Assumes positive numbers def divide(num, divide_by) answer = 0 return answer if divide_by == 0 while(num >= divide_by) num = num - divide_by answer = answer + 1 end answer end puts divide(10,0) Less

Simpler version (assuming you are allowed to use multiplication), just compute the sign at the end and multiply: function divide(a, b){ if(b == 0) throw "Cannot divide by zero"; var remainder = Math.abs(a); var dividend = Math.abs(b); var result = 0; while(remainder >= dividend){ result++; remainder -= dividend; } if(result > 0 && a*b < 0) result *= -1; return result; } Less

http://www.bearcave.com/software/divide.htm

Show More Responses
Qualcomm

How to discover if the given number is Power of 2 ?

4 Answers

return (( x!=0) && (x & (x -1) == 0)) a number which is power of two will have single 1 in binary representation ex. 16 00010000 x-1 will have pattern 00001111 hence x&(x-1) will always be 0 for power of two numbers. Need to check condition for x!=0 since 0 is not a power of two. Special case to handle. Less

if you can figure this out inside an hour, congratulations this isnt something that should be in an interview to be honest the level of difficulty of the answer that algo came up with is at the level of an upper division course that has a proof of it written in wikipedia i honestly like the brute force solution Less

Divide the number by 2, and repeat, until the result is a not an integer number (in this case is not a power of 2) or the result is 1 (in this case the number was a power of 2). Less

Show More Responses
Amazon

Print the number of occurrences of a number in a sorted array of numbers. Input: 1 2 3 4 4 4 4 4 5 6 7 | 4 Ouput: 5

4 Answers

const counter = (array, num) => { let a = numbers.indexOf(num); if (a >= 0) return numbers.lastIndexOf(num) - a + 1; return 0; } Less

how to execute this code const counter = (array, num) => { let a = numbers.indexOf(num); if (a >= 0) return numbers.lastIndexOf(num) - a + 1; return 0; } Less

const sort = (array, target) => { return array.filter(item => item==target).length; } Less

Show More Responses
Amazon

Make an accordion where when clicked, text expands from it and when another item is clicked, the first one collapses and the second one expands.

4 Answers

script - var accordion = document.getElementsByClassName("accordion"); var i; for (i=0; i Less

HTML - <div> <div>element number 1</div> <div>element number 2</div> <div>element number 3</div> <div>element number 4</div> <div>element number 5</div> </div> CSS - .accordion-element { display: inline-block; overflow: hidden; width: 20px; height: 20px; } .accordion-element.expanded { width: auto; } Javascript - function expandElement(elem) { var elementsToRemoveClassFrom = document.getElementsByClassName('expanded'); for (var i = 0; i &lt; elementsToRemoveClassFrom.length; i++ ) { elementsToRemoveClassFrom[i].classList.remove('expanded') } elem.classList.add('expanded') } Less

My answer was shortened by Glassdoor security mechanism. What's missing from my last answer is that for each HTML DIV element I added an "oncl1ck" attribute which called "expandElement(this)" Less

Show More Responses
Amazon

filter table using vanilla js

3 Answers

Assuming it's a simple "equal" filter and the table is a 2-dimensional array like this- var table = [ ['name', 'occupation', 'age'], ['Roy1', 'Software Engineer', '29'], ['Roy2', 'Software Engineer', '26'] ]; I'd go with - function filterTable(table, param, value) { var paramIndex = table[0].indexOf(param); return table.reduce(function (acc, row) { if (row[paramIndex] === value) { acc.push(row); } return acc; }, []) } And then, for example for the input - filterTable(table, 'age', '29') I'd get back - [['Roy1', 'Software Engineer', '29']] Less

var table = [ ['name', 'occupation', 'age'], ['Roy1', 'Software Engineer', '28'], ['Roy2', 'Software Engineer', '29'] ]; function filterTable(table, param, value) { var paramIndex = table[0].indexOf(param); return table.filter(item=&gt;item[paramIndex]===value) } var res=filterTable(table, 'age', '29') console.log(abc) Less

var table = [ ['name', 'occupation', 'age'], ['Roy1', 'Software Engineer', '29'], ['Roy2', 'Software Engineer', '26'] ]; let filterTable = (table, field, val) =&gt; { const col = table[0].indexOf(field); return table.filter(row =&gt; row[col] === val)[0]; } let res = filterTable(table, 'name', 'Roy2'); console.log(res); Less

Amazon

How would you reverse a linked list?

3 Answers

For a singly-linked list consiting of n linked nodes... i -2) { node[i+2].next &lt;-- &amp;node[i+1]; i = i - 1; } node[0].next &lt;-- null; Less

dave, the tricky answer given below is not acceptable in interview as well as in real programming. Please dont take these words as negative but try formulating solutions which are simple to understand and elegant. for example the invariants in above code and termination condition of -2 is not good. for example you can write -- Node* prev = &amp;head; Node* curr = prev-&gt;next; while(curr) { Node* tmp = curr-&gt;next; curr-&gt;next = prev; prev=curr; curr = tmp; } return prev; Less

This tutorial answers your question: http://youtu.be/LgapVjJYxqc

Qualcomm

Binary tree , left node has smallest value . Print 5 10 20 25 and then “count of nodes=4”…

2 Answers

recursion ... defined "current=head" in the method so it doesn't changes ofcourse, even if I sent current.next in recursion... don't be nervous! Less

Did not get this question? Could you please eleborate it more?

Viewing 1 - 10 of 95 interview questions

See Interview Questions for Similar Jobs

php programmer web applications developerjava web developersr web developerc net software developer

Glassdoor has 95 interview questions and reports from Web development engineer interviews. Prepare for your interview. Get hired. Love your job.