Jack's team was hiring a new web developer. As part of their interview process, they asked for some code samples- whether a public Github or just snippets to review. The goal isn't to be one of those companies that requires a super active Github history, but it's just helpful to get a sense of how someone approaches writing code before diving into some of the deeper interview challenges. No one has ever been disqualified for not being able to provide code, it just can streamline the interview process.

As it turns out, it's also a pretty great filter for excluding candidates that probably shouldn't move on to the next round, or in this case, shouldn't be allowed to program at all.

<?php
  $screenWidth = "<script type='text/javascript'>document.write(window.screen.availWidth);</script>"
  $screenHeight = "<script type='text/javascript'>document.write(window.screen.availHeight);</script>";
  echo"Resolution: ".$screenWidth." x ".$screenHeight."<br>Done!";
  
  $width = intval($screenWidth);
  $height = intval($screenHeight);
  
  echo"<br>".$width."<br>";
  echo"<br>".$height."<br>";
?>

I want to stress, this is a code block the candidate supplied. They wanted to impress an interviewer, and said, "Yeah, this'll do the trick." Which, in their defense: I am impressed. I've never seen anything quite like it.

The developer understood that getting accurate information like "how big is the window" requires access to the client side. So they wrote some JavaScript that writes the window size information to the body of the HTML page, on the client side. Their approach is very much a "my programming skills begin and end with copy/pasting from StackOverflow", but the first three lines of this script do what you'd expect, if awkwardly: injected JavaScript will cause the page to print the resolution into the body of the page.

It's the next few lines where things go off the rails. They call intval on the JavaScript strings. I can only imagine that they believed that they could somehow read the contents of JavaScript from the server side, which… isn't how this works. It demonstrates a complete misunderstanding of everything about how web development works.

Suffice to say, this particular candidate didn't move on to the next round.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!