Doctor JavaScript?

Learning JavaScript bits through Doctor Who is possibly the best thing ever.

I Did All the Things

Finally finished up the last 6 Coderbyte challenges. I had planned to finish them on Tuesday but I got home from an all day work “thing”, took a shower and passed out. On Wednesday I had a much-needed pajama party with relatives and watched some old Downton Abbey (season 2, Matthew just got the use of his legs again *sniff*). The last 6 challenges were plagued with me forgetting what variable type I was juggling. Most of my errors were fixed by type conversions. I still believe nothing was as hard as that stupid Array Addition. Everything else I was able to piece together on my own, but I don’t think I would have ever solved that one without a bit of a nudge from other coders. I think I need more math logic. I should probably take a class or find a good book (oh the torture) on the subject. I plan on reading through Professional JavaScript for Web Developers over the weekend and maybe running through all 26 again (no peeking!) on Sunday as prep for Tuesday’s interview. After I get in (I need to tone down the bravado), I want to go back and try the harder challenges. Wish me luck on everything! Also, as always, my Github with the updates. My favorite code this time was MeanMode which checks to see if the mean and the mode of an array are the same. It’s probably my favorite because I literally couldn’t remember what the mode of an array was and had to look up remedial math stuffs. That was humbling.

function MeanMode(arr) {  
  var mode;  
  var modeCount = [];  
  var count = 0;  
  var sum = 0;  

  for (i = 0; i < arr.length; i++) {  
    sum += arr[i];

      modeCount[arr[i]-1] = 0;  

    modeCount[arr[i]-1] += 1;  
  for(i = 0; i < modeCount.length; i++) {

    if(modeCount[i] > count) {  
      mode = i+1;  
      count = modeCount[i];  

  var mean = sum/arr.length;

  if (mean === mode) {  
    return 1;  
  } else {  
    return 0;  

Jack Standard

Evil Jack

More cat pictures!, you cry? Happy to oblige. Jack again, being his standard needy self. Someday I’ll get a good picture of my other boy, a tuxedo named Isaac (he’s camera-shy).

Solver of Problems

I figured it out! Sort of on my own, sort of studying how others had “solved” it in different languages (a few of the “solutions” didn’t seem to work). Array Addition I is now my bitch. Also the next 10 easy problems from Coderbyte are on my GitHub. 6 more to go (well 7 actually, I gave up on ArithGeo, but the solving of Array Addition gives me hope that I will figure it out tomorrow). Problem description: Using the JavaScript language, have the function ArrayAdditionI(arr) take the array of numbers stored in arr and return the string true if any combination of numbers in the array can be added up to equal the largest number in the array, otherwise return the string false. For example: if arr contains [4, 6, 23, 10, 1, 3] the output should return true because 4 + 6 + 10 + 3 = 23. The array will not be empty, will not contain all the same elements, and may contain negative numbers. And my solution: (basically grabs the largest value out of a provided array and it runs through all the possible sum combinations of all the other numbers to see if one of those sums equals the largest values)

function ArrayAdditionI(arr) { 
  arr.sort(function(a,b){return a - b})
  var largest = arr.pop();
  var sum = 0;

  for (var i = 0; i < arr.length; i++){
    sum += arr[i];

    for (var j = 0; j < arr.length; j++){
      if (i != j) {
        sum += arr[j];
        if (sum == largest) {
          return true;

    for (var k = 0; k < arr.length; k++) {
      if (i != k) {
        sum -= arr[k];
        if (sum == largest) {
          return true;

    sum = 0;

  return false;      

Coderbyte and Me

I’ve been practicing my JavaScript for the HackReactor interview on the 20th (wish me luck by the way). They sent around an email saying to be prepared so you didn’t have to reschedule (I’m suddenly glad I couldn’t get an appointment straightaway). They recommended being able to get through all the easy challenges on Coderbyte in < 5 minutes. Yikes? Surprisingly not. I’m having a lot of fun.

There are a couple things I’ve obviously forgotten (I had to look up the regex to keep only alpha characters, I suck at regex), but I’m pretty fast. I’m also realizing just how not amazing I am at the trickier puzzles. There are one or two in there that I still don’t understand, even after I caved and looked up how others solved them (Array Addition I, I’m glaring at you).

There are 26 easy challenges. I’ve decided to run through at least 10 a day, so I finished the first 10 today and uploaded them to my GitHub. My favorite one so far was the TimeConvert, which took a number (e.g. 126) and converted to the amount of hours and minutes (e.g. 2:6). I could have made it prettier by added a preceding 0 in the minutes, but the goal of these is speed and the instructions didn’t ask for that pretty extra. This was my favorite because I just have this weird love for modulus. The code to solve it:

function TimeConvert(num) { 
  var minutes = num % 60;
  var hours = parseInt(num/60);

  return "" + hours + ":" + minutes;         

Slogging Updates

I got a conditional acceptance from App Academy. I have to do the homework and take one more coding test before they will let me in because I bombed the last coding interview. I’m actually not upset at all. I was worried that I was going to feel obligated to go when I really want to see how my interview with Hack Reactor goes. I understand that App Academy would be a good choice from a finances perspective, but the raw talent that they seem to be churning out of Hack Reactor is really intriguing, especially when Ruby isn’t my favorite language and JavaScript was the first one I ever learned.

Updates as they come! Hack Reactor interview isn’t until the 20th and I probably won’t try to finish up the App Academy homework until around that time as well.

Everyone’s On It

I just made something! For the first time ever I made a stupid little ruby program to do something that a PivotTable was giving me fits over at work. I had a spreadsheet like so:

Spreadsheet of Traits

But what I really needed was a text file that I could print and hand out to people like so:

Formatted Strengths

And I did it with the power of Ruby! I was so proud of myself. I’ve never taken a real world problem (from my work no less) and made a tiny bit of code do exactly what I want it to. It just adds to my love of coding.

require 'csv'

contents = "strengths.csv", headers: true, header_converters: :symbol"out.txt", 'w') do |f|
  contents.each do |row|
    headers = contents.headers
      name = row[0]
    strength = {}
      i = 1
    while i < row.length
      if row[i]
        strength[(row[i].to_i)] = i
      i += 1
    f.write("#{name} \n")
    stren = strength.sort_by { |k, v| k }

    stren.each do |k,v|
      f.write("\t #{headers[v].to_s.capitalize} \n")

And yes, those are my StrengthsFinder top 5 in the second picture. Everyone at work had to do them and I think mine are very accurate.