Heck, we can't even decide what a web developer actually does, as opposed to a web designer, or "growth hacker", or UI/UX "expert", or back-end programmer.
How can we set a minimum when we can't clearly define the task beforehand?
Heck, we can't even decide what a web developer actually does, as opposed to a web designer, or "growth hacker", or UI/UX "expert", or back-end programmer.
How can we set a minimum when we can't clearly define the task beforehand?
This is not even testing an obscure application of closures. I mean, the trick here is not knowing about closures, but about knowing the details of the setTimeout function -- specifically, that there is a corresponding clearTimeout function (which, as a non-specifically frontend developer, I had long forgotten if I ever knew it).
That's not testing programming competency, that's testing knowledge of the JS standard library, and secondarily knowledge of closures. I mean, it's a legitimate thing to test for, but let's not pretend it's somehow analogous to fizz buzz.
Edit: And none of you even mentioned the error in his code, which another commenter pointed out: wrong function. It should have been clearTimeout
I've been asked similar questions in interviews, and when I haven't known the little bit of factual information required (in this case the existence of setTimeout and clearTimeout), I've asked to Google it, and my interviewers have always been more than happy to let me. I've passed interviews doing this. I've even had friends who do interviews tell me that 'googling an answer' is often the correct answer.
I personally think the choice of setTimeout/clearTimeout was a really good one because almost all JS devs will know it, but it's also really easy to find online if you know what you're looking for. This test is really about coming up with a good way to solve a problem.
setTimeout is something I had to learn about very early in my web development career. The essentials of jQuery too. Callbacks too, unless all you need is someone who does mainly html+css with a bit of jQuery. The interviewer asked exactly the kind of question that I'd consider a 'minimum'.
Of course, as others have pointed out, it also depends on what you're looking for. If you're okay with someone who can learn a lot on the job, and if you don't mind that this person has some basic things to pick up on, you'll probably be focusing more on how the interviewee approaches the problem, and how they interact with you as the interviewer.