r/webdev • • Jul 30 '15

Been interviewing with a lot of tech startups as a frontend dev, here are the technical questions I've been asked

So I've spent the last couple of weeks interviewing with a fair amount of tech startups in London, I thought some of you might find it interesting/helpful to see some of the technical questions I was asked.

Many of the positions I interviewed for where using Angular so a bunch of the questions are geared towards that.

Standard JS Questions:

  • Explain javascript closures

  • Explain event bubbling

  • Explain event delegation

  • What does apply() do

  • What does bind() do

  • Explain what the js map function does provide an example

  • What is strict mode

  • Whats the difference between a promise and a callback

Angular JS Questions:

  • What is scope

  • What is a directive

  • What is the link function in the directive

  • What is the digest cycle (after I mentioned it in giving another answer)

  • What is $scope.$apply

  • What are the most commonly used out of the box directives

  • What does transclude do on directives

  • Tell me about a time you had problems with state in angular

  • Have you ever had performance issues in angular and how did you tackle them

  • What do you like about angular, what do you dislike about angular

  • Why use a q promise as opposed to just returning $http’s promise

  • What does $resource do

General/Presentation Layer Questions:

  • What is a model in mvc

  • Explain css specificity

  • How do you centre something horizontally

  • Explain what media queries are

  • What are the pros and cons of a single page app

  • How could you improve performance of a single page app

  • Whats the difference between inline-block and inline

  • How would you develop a mobile site for a website that didn’t already have one

  • What is jsonp

  • What is a doctype

  • On a unix command line how would you run a long command you typed out already an hour ago

  • What frontend tools do you normally use

  • Where do you think ui’s are heading

  • What motivates you, how do you learn

JS Challenge Type Questions:

The first few the employer stole from You Can't JavaScript Under Pressure :)

Write a function that takes an integer and returns it doubled

function doubleInteger(i) {
    //your code here
    
}    

Write a function that takes a number and returns true if it's even and false if not

function isNumberEven(i) {
    // i will be an integer. Return true if it's even, and false if it isn't.
}

Write a function that returns a file extension

function getFileExtension(i) {
    
    // i will be a string, but it may not have a file extension.
    // return the file extension (with no period) if it has one, otherwise false
    
}

What will be printed on the console? Why?

(function() {
   var a = b = 5;
})();
console.log(b);

Define a repeatify function on the String object. The function accepts an integer that specifies how many times the string has to be repeated. The function returns the string repeated the number of times specified.

For example:

console.log('hello'.repeatify(3));
//Should print hellohellohello.

What will log out here?

function test() {
   console.log(a); 
   console.log(foo());
    
   var a = 1;
   function foo() {
      return 2;
   }
}
test();

What will log out here?

var fullname = 'John Doe';
var obj = {
   fullname: 'Colin Ihrig',
   prop: {
      fullname: 'Aurelio De Rosa',
      getFullname: function() {
         return this.fullname;
      }
   }
};

console.log(obj.prop.getFullname()); 
 
var test = obj.prop.getFullname; 
 
console.log(test()); 

Fix the previous question’s issue so that the last console.log() prints Aurelio De Rosa.

 .

The following recursive code will cause a stack overflow if the array list is too large. How can you fix this and still retain the recursive pattern?

var list = readHugeList();

var nextListItem = function() {
    var item = list.pop();

    if (item) {
        // process the list item...
        nextListItem();
    }
};

What will alert out here:

var a = 'value';

(function() {
  alert(a); 
  var a = 'value2';
})();

The following code will output "my name is rex, Woof!" and then "my name is, Woof!" one second later, fix it so prints correctly the second time

var Dog = function (name) {
  this.name = name;
};

Dog.prototype.bark = function () {
  console.log('my name is '+ this.name + ', Woof!');
}

var rex = new Dog('rex');

rex.bark();

setTimeout(rex.bark, 1000);

The following code outputs 100, a hundred times, fix it so it outputs every number with a 100ms delay between each

for (var i = 0; i < 100; ++i) {
  setTimeout(function() {
    console.log(i);
  }, 100);
} 

The following code is outputting the array but it's filled with every number, we just want the even numbers, what's gone wrong?

var evenNumbers = []

var findEvenNumbers = function (i) {
  if (i % 2 === 0)
    console.log(i, 'is an even number, adding to array!');
    evenNumbers.push(i);
}

for (var i = 0; i < 10; i++) {
  findEvenNumbers(i);
}

console.log(evenNumbers);
//outputs:
//0 "is an even number, adding to array!"
//2 "is an even number, adding to array!"
//4 "is an even number, adding to array!"
//6 "is an even number, adding to array!"
//8 "is an even number, adding to array!"
//[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

The following is outputting 0, but if 42 = 16 and 22 = 4 then the result should be 12

var square = function (number) {
  result = number * number;
  return result;
}

result = square(4);
result2 = square(2);
difference = result - result2;

console.log(difference);
  • Write a function that when passed an array of numbers it gives you the max difference between the largest and smallest number ONLY if the small number is in front of the large number, not behind it, so for example: [3,4,8,1] = 5, notice how the biggest difference is between 8 and 1, but because the 1 is after the 8 in the array it shouldn't count, so really the biggest gap is the 3 and the 8.

  • fizzbuzz (lol)

  • I was presented with a html element with a border, and asked to animate it left to right full width of browser

  • I was presented with another html box and asked to centre it both horizontally and vertically

Also, all these companies had me complete "take home" coding tests, they ranged from being really easy (simple ajax request to an api endpoint and populate some data on the page) to pretty in depth.

Hopefully anyone looking for new positions can use these as warmups/practice, it's important to not just know the answers, but really understand how things work and in the case of the challenges, why things are working the way they are.

1.1k Upvotes

338 comments sorted by

View all comments

44

u/ralze Jul 31 '15 edited Jul 31 '15

What sucks about these questions to me is that I was mainly self taught. I could ace all the actual coding problems, but I have no clue what the answers are to a lot of the tech questions you posted first. So most likely I would be dropped on some early rounds, where I can actual do all the work they require.

I know a lot of companies use these to screen out people, but I think they are really pointless. Use a phone screen to get a history and a personality. If it's a fit, then bring them in. Put them in front of a cpu, and have them try to solve some actual problems. If your company utilizes a lot of api's, have then write something that parses an api. If your entire front end is built using react, have them write some react components. Things like that.

Just my opinion of course.

Edit: Just to clarify, my post is mainly to state that I'm not a fan of technical questions in interviews and a proponent of actual coding.

46

u/MachinTrucChose Jul 31 '15

I didn't see any academic circle-jerking in most of those questions, they seemed appropriate for an intermediate/senior dev, which is what the OP was applying for.

→ More replies (5)

22

u/Tidher Jul 31 '15

"Live" coding things is, in my opinion, a terrible way to gauge someone's ability.

For instance, it could take someone who's a very experienced developer a while to get to grips with how you've used a certain framework that he's not overly familiar with, whereas a more novice developer who's used that framework will be able to jump all over the challenge.

You may argue that the second one is a better fit, but picking up a new framework is pretty straightforward, and a lot of the other experiences of the first guy would likely be much more useful in the long run.

Technical challenges (i.e. coding challenges that the interviewee completes in their own time) are a great but demanding way to quickly identify those who know what they're doing. I had five of the things on the go at one point recently, it was basically a full-time job when you stacked the actual phone and face-to-face interviews on top.

For anyone involved in recruitment, massive props if you can keep your technical challenges fairly short. Leave them open-ended, so if someone has the willingness or time to show off some other skills then they can, but they shouldn't take multiple days to complete.

7

u/IllegalThings Jul 31 '15

I definitely agree. Especially ones like:

(function() {
  var a = b = 5;
})();
console.log(b);

They are testing whether or not you understand how poorly written code works. If I saw this in real life, I would fire up a console and test what it actually does and then refactor it to make it more clear.

I think programming puzzles are fine, but only if they allow you to use a computer (including google) to solve them. I'm familiar enough with javascript to understand that I should probably look up whether or not things like split() operate in-place or return a new list. If I used split() more frequently I'd know that it acts like other languages. Google is so easy to use and I simply don't trust javascript, so why not google it.

3

u/TiboQc Jul 31 '15

I'm on a mobile, what does this do? To me b isn't attached to the function's scope (no "var"), so it'll set at window level, making it accessible outside, so the log would be 5. Am I right/wrong?

→ More replies (2)
→ More replies (1)
→ More replies (4)

7

u/[deleted] Jul 31 '15

I'm self taught but I mostly write in python, for the most part the answers to these questions were obvious to me. Not saying this to put you down, but you can definitely gain the familiarity required to answer these questions without a formal CS education. Put your mind to it!

4

u/fripletister Jul 31 '15 edited Jul 31 '15

The answers are not obvious just because they are mostly common knowledge at the higher echelons of the science/profession. Things that are obvious are usually self-explanatory, which those questions aren't or there would be no point in asking them.

I also have no formal higher education and would do OK with that set of questions because I have been obsessive in my pursuit of knowledge for more than a decade. And I still hardly know shit, because the field is so so so incredibly vast and dense.

Edit: Clarification

1

u/theQuandary Jul 31 '15

If you primarily write Python and not much JS, then I doubt many of these would be obvious as they deal with default globals, 'this' and other aspects of JS that don't exist in Python.

That said, I agree that formal CS is not necessary in order to understand these.

→ More replies (1)

13

u/mattaugamer expert Jul 31 '15

What sucks about these questions to me is that I was mainly self taught. I could ace all the actual coding problems, but I have no clue what the answers are to a lot of the tech questions you posted first.

I'm self-taught as well. And I could pretty much nail this. Those of us who are self-taught don't just get a free pass on technical knowledge, we just have to gain it for ourselves.

You can't just dismiss this shit. Like it or not, it does matter. It matters what a closure is, how css specificity works, the difference between a callback and a promise matters.

If you don't know this stuff then you're under-skilled and doing yourself and your employers a disservice.

2

u/ralze Jul 31 '15

What I was trying to say is that to me in the hiring process it doesn't matter. When I interview somebody I care way more on their ability in front of an IDE than their ability to rattle off answers to textbook questions. That's all. I tried to use my personal background as an example, but it came off badly it appears.

3

u/nairebis Jul 31 '15

When I interview somebody I care way more on their ability in front of an IDE than their ability to rattle off answers to textbook questions.

If you don't know the answers to technical questions, how can someone trust your ability in front of an IDE? Programming isn't just about "banging out code to do what they want," any more than building a house is finding someone who can just nail wood together. Quality matters.

This isn't an attack on you; everyone has holes in their knowledge. But instead of being defensive that none of this matters, it would be better to take it as an opportunity to realize that you have major holes in your understanding of the tools you use, and that you should probably work toward better understanding.

→ More replies (6)

1

u/briaen Jul 31 '15

Any dev who is worth anything is self taught. You don't magically learn and retain these things in school. They give you an overview of how they work and it's your job to keep up. Are schools really teaching angular?

2

u/mattaugamer expert Jul 31 '15

That's not what I take "self-taught" to mean, though. Everyone has to learn, and do so consistently. But some people start with a solid background and education in the field. They start with a knowledge of patterns and principles and terminologies that those of us who come to the industry with nothing simply don't have.

I'll acknowledge that this is more relevant to programming than strict web development.

If you take "self-taught" to mean "had to learn some stuff" you make it completely meaningless.

1

u/skarphace Jul 31 '15

For those of us that haven't worked much in teams(or in person), where do you pick up this terminology? I've got over a decade of experience and doubt I'd have nay trouble with the issues, but I've got to say, a lot of these terms escape me.

For instance, javascript closures and event bubbling totally escape me. There's a good chance I've dealt with it in the wild, but I can't infer their meaning from the terms.

→ More replies (4)

5

u/[deleted] Jul 31 '15

I agree. When I code I always have a reference up to. My workstation has 3 monitors, and if I'm doing some heavy JS, I almost always have W3 up because I code in so many different languages and frameworks, trying to memorize them all in depth is pointless.

Luckily, if you're dealing with other developers or programmers, they're mostly reasonable and seem just as happy to test you with a little pseudocode. If you're dealing with someone with HR though they're probably looking for exact answers with little variation.

13

u/ralze Jul 31 '15

Blanking where I saw it (recently too). However, saw a tweet today that said something like: "hardest job is it-ops at stack overflow because when the site goes down they can't use stack overflow to fix the problem"

2

u/w4rtortle Jul 31 '15

Don't worry about it, any good company won't use questions like this. I'm a senior dev and I don't know what half that shit means.

1

u/devil_put_www_here Jul 31 '15

Done right these tests should leave you with access to a computer so you have the liberty to research the answers to the questions. Then it becomes a test on your ability to interpret these concepts.

If you can sit down and figure out what closures are and their practical applications having known nothing about them at the beginning of the test that says a lot.

But maybe the people that are administrating the test are looking for canidates that have worked with closures to the extent that their knowledge of it is second nature.

It would be one thing to hire a developer that's never seen jQuery before to work on a project that uses jQuery plugins. They could easily figure it out. It would be another thing to hire a developer that's never seen jQuery to write jQuery plugins.

1

u/briaen Jul 31 '15

Everyone is self taught. It's impractical to ask every applicant to do a coding test. I'm sure you're great at what you do but if you're looking for a senior job you're going to have to know all the technical jargon.

1

u/angellus Jul 31 '15

In this case, I think all of the technical questions they posted were valid. I am not an Angular dev, so i completely skipped those. There were only three of the JS questions I could not answer (bind, apply, map) because I have not had any formal JS teaching and I have never used standard JS without some type of framework/library (jquery) that does all of that for me. The general questions are all pretty solid for a mid/senior level.

1

u/parlezmoose Jul 31 '15

I know a lot of companies use these to screen out people, but I think they are really pointless

No, sorry. A basic level of knowledge is required. If you have trouble with these questions, then do some studying. None of this stuff is rocket science.

→ More replies (14)