DEV Community

5 Unusual Test Questions I Got While Interviewing for Web Dev Roles

Jen Chan on December 28, 2017

Poor [Mister Unicorn](http://misterunicorn.com/index.php?/books/unicorn-being-a-jerk/) Update: I changed the title from β€œ5 Questions Companies A...
Collapse
 
cristinasolana profile image
Cristina Solana

"don’t look up documentation online" - when you hear this, run.

Collapse
 
aeiche profile image
Aaron Eiche

Agreed. It's fortunate that I've never run into this myself, but my immediate response to that sort of thing is "Do you expect your employees to not utilize documentation while at work?"

It's absolutely absurd.

Collapse
 
jenc profile image
Jen Chan

My gut feeling -giving them the greatest benefit of the doubt- is that they think you've used certain methods so much you'll remember...

Collapse
 
jenc profile image
Jen Chan

Unfortunately I’ve had this a couple times. (Sits in room flicking pencil)

Collapse
 
yechielk profile image
Yechiel Kalmenson

Once saw someone tweet that they'd respond to such a question saying "that's an interesting problem, do you come across this often here?"

You may not want to try it at home ;)

Collapse
 
jenc profile image
Jen Chan

You may enjoy this thread twitter.com/RebeccaSlatkin/status/...

Collapse
 
yechielk profile image
Yechiel Kalmenson

lol, some great replies there!

Collapse
 
giacomosorbi profile image
Giacomo Sorbi

The last one is actually a fairly plain regex problem: why should anyone use Arrays or OOP here? The latter at best if they want you to implement a new String method, ok, but meh...

Collapse
 
jenc profile image
Jen Chan

I imagine you meant Q7 by the "last" question. I'm curious how you'd solve that with regex; I didn't suggest it because I don't know any better. I would struggle to remember character patterns.

Collapse
 
giacomosorbi profile image
Giacomo Sorbi • Edited

Of course I meant the last one.

It is a pretty trivial task, to be fair:

String.prototype.count=function(elem, caseInsensitive = true){return (this.match(new RegExp(elem, `g${caseInsensitive ? "i" : ""}`))||[]).length;}
"Pippi".count('p'); //returns 3
"Pippi".count('p', false); //returns 2

On request I can offer code in Python, Ruby, Crystal and possibly something more.

Oh, and Pippi is my cat <3

Thread Thread
 
jenc profile image
Jen Chan

Thanks for illustrating that. It’s a new way of looking at it. And yes, in hindsight that question is not unusual.

I got that q twice in no-documentation situations so i just iterated through a string and return the number of truthy values. Not as rigorous or pure, but gets the job done.

Thread Thread
 
giacomosorbi profile image
Giacomo Sorbi • Edited

I assume you mean "situations in which I could not google" or the like; it might have been more efficient then to filter, at least space wise, instead of mapping a string and then running through an extra item of length n to count again.

Better yet, a reduce approach, to keep it in n time.

I would still think that a RegExp-based approach would have an edge in terms of performances, as long as you use NodeJs which has some really impressive regex engine under the hood, but I am too busy (or lazy) to build a jsperf about it right now.

If you fancy some practice with this kind of stuff, come and join us on CodeWars - it is cool and we have a rather good community.

Edit: oh, cool, this place support the git-flavored markdown! Edited the snippet above!

Thread Thread
 
jenc profile image
Jen Chan

Yes, I meant what you meant, but said "no documentation" to include situations where interviewers would throw you an O'reilly book or pdf for reference, but insist you can't code with internet.

Does every char make a difference? I read somewhere that for loops are still faster than forEach. Is coding an exercise like copywriting for sentence refinement? For me the thing got me into coding were the sexy results (coming from a background in video, things like animation didn't need to be rendered ahead of time as a huge file, if they could be executed as code, but of course, you could heat up your computer and slow down the browser etc ). But I can tell bad performance would impact quality and users would bounce away, so these things matter.

I agree with using the map and reduce functions. It makes a lot of sense. I only just got used to using map without errors!

At the risk of looking stupid in a euler-project style community I feel should ready myself by reading the aforementioned stack of books in my post, which have just arrived from Manning. I'm particularly excited about grokking algorithms, as a visual learner. I never learned code by reading books, but I realize there's some persnickety things you just don't learn by doing, then doing exercises after reading. It's a very different way of learning.

Also, is codewars for-pay? Must you be part of a "clan"? God I don't like that term.

Collapse
 
jazzmalang profile image
Mark Gugler

Although I agree these interview questions are absurd, there is a good amount of merit to seeing peoples responses. I've been to interviews where I didn't answer a single question right and still got the job. I approached each question as a collaborative effort with the interviewers. "Don't look up documentation online" (if it is a good interviewer) really means "Ask me for help".

I will add though, if you're given a task and a set amount of time with no internet/resources while they leave the room. Walk out. Development should never be in a vacuum.

Collapse
 
jenc profile image
Jen Chan

In hindsight I think the hamburger sandwich menu question and the final 2 (number 5 and 6) aren't unusual to test on devs, but seeing how they tackle it without other prompts would definitely be interesting. (Under pressure my tendency is always to write more code than i need-_-) I also do like the ask-for-help thing, if they make themselves available for that.