In this series I attempt to complete Free Code Camp as quickly as possible, without cutting too many corners. For an introduction to this series, see Free Code Camp #0: Speedrunning Free Code Camp. This entry covers the following sections:

  • Basic JavaScript (est. 10 hours)
  • Object Oriented and Functional Programming (est. 2 hours)
  • Basic Algorithm Scripting (est. 50 hours) (required)

Things went pretty quick, since I'm still in familiar territory. The algorithms section contained 17 different exercises. Implementing rot13 is representative of the average difficulty of the exercises.

function rot13(str) { // LBH QVQ VG!
  return str.split("").map(function(s0) {
    if (s0.match(/[A-Z0-9]/)) {
      return String.fromCharCode(((
        s0.charCodeAt() - "A".charCodeAt() + 13
      ) % 26) + "A".charCodeAt());
    } else {
      return s0;
    }
  }).join("");
}

New things I have learned:

  • Array.prototype.shift() pops to the left.
  • Array.prototype.unshift() pushes to the left.
  • Array.prototype.slice() is a better substr that works for arrays too.
  • arguments isn't actually an Array, it's just Array-like.

In the next entry I will start on the Intermediate Front End Development Projects, and access some JSON APIs using jQuery.