PHP

Harmful Technical Interview Questions

Junior dev's life is hard an full of dangers. You come to technical interview and think "at least I'll learn something new from guys that know it better than me". Well, not really. Threre are some things that are ok in interviews and are totally wrong in real life. Here are some examples.


PHP Question: What would be the output of this code below?

$x = 5;
echo $x+++$x++;

Expected answer: 11

Real life answer: Just run it - that's not an rm -rf /. And then run git blame. I need to talk to person who wrote this. You shouldn't make unreadable code unless you have a real good reason to do it. And if you have that reason — first describe it in comment block so I know that you're not totally wrong. Something like /* My cat forced me to do that. Please call 911 */ would be ok.


JS Question: Please make a function isInteger.

isInteger(x)

Expected answer: [some code]... Oh, I forgot about numbers like 1e+21... [some another code]... Oh, I forgot about something Infinity... [cries silently]

Real life answer: This can be googled in 15 seconds. That's one of the most basic tasks — surely it was already solved. Why are you reinventing bicycle if someone smarter that you made it years ago?


JS Question: Please make a function isPalindrome.

console.log(isPalindrome("level"));                   // logs 'true'
console.log(isPalindrome("levels"));                  // logs 'false'
console.log(isPalindrome("A car, a man, a maraca"));  // logs 'true'

Expected answer: Here, it works.

function isPalindrome(str) {/* some code */}

console.log(isPalindrome("level"));                   // logs 'true'
console.log(isPalindrome("levels"));                  // logs 'false'
console.log(isPalindrome("A car, a man, a maraca"));  // logs 'true'

Real life answer: Here, it works and kinda unit tested.

function isPalindrome(str) {/* some code */}

console.log(isPalindrome("level") === true);
console.log(isPalindrome("levels") === false);
console.log(isPalindrome("A car, a man, a maraca") === true);

Because without tests nobody knows that it works.


Tags: , ,

Comments