Hack Reactor pre-course work

The last six weeks have flown by pretty quickly. My cohort (24/25) received our pre-course work on December 8th and it's been a blast learning it.

The pre-course work builds up on all the skills you learned going into your technical interview. There is a lot of functional programming, a good chunk of jQuery, and something called recursion (scary. okay, not really). Sprinkled along the way are a lot of tutorials on Git, some Code School courses, and a lot of fun optional work.

Functional Programming

One thing I'm starting to realize is that I'll approach a new concept or technology with enthusiasm, fail at it, fear it, and then somehow end up conquering it and looking back thinking "wait, that was it?". Functional Programming is definitely one of those moments. I recall this concept completely kicking my ass a few months ago, especially with Underscore.

The first part of our pre-course work involves tackling Underscore. It's a popular Javascript library that offers a large collection of very useful helper functions that will make your life easier. It's like a swiss army knife for functional programming.

For example, take the Underscore function "each". It accepts two parameters: A collection (either an array or an object), and an iterator (this is a function you would pass in). "each" will cycle through, well, each element inside your collection. For every element it cycles through, "each" will run your iterator function and pass in the element as the iterator function's parameter.

I'm probably making this sound a lot more complicated than it seems, so let's try and explain it one level down

"each" runs a for-loop through either an array or an object. This for-loop then calls a function on each element of that array or object. The function that gets called is passed through "each" at the start.

var each = function(collection, iterator){
  // check to see if collection is an Array or an Object
  // run an appropriate for-loop depending on type
  // this is the for-loop if it is an array
  for (var i = 0; i < collection.length; i++){
    // for every element in the collection, call the iterator.
    iterator(collection[i], i, collection);

Our Functional Programming pre-course work involved building a good chunk of the Underscore library from scratch, as if it were being invented for the first time. It was really fun and helpful because it gave me a more intimate understanding of how these helper functions work, rather than just knowing what they do.

jQuery and Bootstrap

The second part of our pre-course work involves building the front-end of a Twitter clone. Here's how mine looked when I was done:

I was a bit familiar with jQuery from my initial interview prep (which was not fully necessary, by the way), but was a complete stranger to HTML and CSS so I watched a tutorial on Code School to get a grasp on it.

The next thing I wanted to do was have a nice layout, one that looked at least like something Twitter designers would create (and one that I'd be happy to use). I went and downloaded Bootstrap. Bootstrap is a framework created by employees at Twitter, initially to streamline the design of their internal tools. I grabbed a free Bootstrap theme and went tinkering around to build the layout that I wanted. About three weeks after I finished this assignment, Code School released a really cool course on Bootstrap.


Recursion is about reducing a large problem over and over again into smaller problems of the same form. This Stanford article probably does a much better job of explaining it than I do, so I'm going to quote heavily from it. It's a really good read and if you have the time and curiosity, I encourage you to check it out.

The following example is directly from the article above, but paraphrased

Think about a large goal like, say, raising one million dollars for a charity. Let's assume the following are true:

  • You don't know any generous millionaires.
  • The average donation to your charity hovers around the $100 range.
  • You don't have ten thousand friends.
    • Even if you did, not all of them would donate.

Thinking about this problem with recursion, the solution would be this:

  • Take ten volunteers in this charity and make them "Regional Coordinators", each responsible for a certain geographic area of the country (or countries) you're raising money in. Your Regional Coordinators are each in charge of raising $100,000.
  • Your Regional Coordinators will probably do the same, getting ten people to each raise them $10,000.
  • This chain can go on and on, just like a pyramid scheme (It's not a pyramid, it's a trapezoid!), until we get to a point where someone is in charge of raising $100. Since the average donation to this charity is $100, chances are that person is going to be the person donating the money.

This is called a "base case", and recursion is about finding these base cases and recurring a function over and over again until the larger problem is solved.

The Recursion part of our pre-course work involved re-building some well-known helper functions with the use of recursion. It was very helpful and I had a blast doing them.

That's pretty much all I have for now. I'll try and write one or two more posts before I start Hack Reactor, and then attempt to post at least once a week.